FruitBank/Presentation/Nop.Web/Themes/CarHaven/Content/pack-frames.ps1

74 lines
2.1 KiB
PowerShell

# Pack vault frames
$framesDir = "D:\REPOS\MANGO\source\FruitBank\Presentation\Nop.Web\Themes\CarHaven\Content\frames"
$output = "$framesDir\vault-bundle.jpg"
$count = 323
Write-Host "Packing $count vault frames..."
$frameBytes = @()
for ($i = 1; $i -le $count; $i++) {
$path = Join-Path $framesDir ("frame_{0:D4}.jpg" -f $i)
$frameBytes += ,([System.IO.File]::ReadAllBytes($path))
}
$headerSize = 4 + $count * 8
$ms = New-Object System.IO.MemoryStream
$bw = New-Object System.IO.BinaryWriter($ms)
# Write frame count
$bw.Write([uint32]$count)
# Calculate offsets and write header
$currentOffset = $headerSize
for ($i = 0; $i -lt $count; $i++) {
$bw.Write([uint32]$currentOffset)
$bw.Write([uint32]$frameBytes[$i].Length)
$currentOffset += $frameBytes[$i].Length
}
# Write frame data
for ($i = 0; $i -lt $count; $i++) {
$bw.Write($frameBytes[$i])
}
[System.IO.File]::WriteAllBytes($output, $ms.ToArray())
$bw.Close()
$ms.Close()
$size = (Get-Item $output).Length / 1MB
Write-Host "Created vault-bundle.jpg ($([math]::Round($size, 1)) MB)"
# Pack forklift frames
$flDir = "D:\REPOS\MANGO\source\FruitBank\Presentation\Nop.Web\Themes\CarHaven\Content\forklift-frames"
$flOutput = "$flDir\forklift-bundle.jpg"
$flCount = 120
Write-Host "Packing $flCount forklift frames..."
$flBytes = @()
for ($i = 1; $i -le $flCount; $i++) {
$path = Join-Path $flDir ("frame_{0:D4}.jpg" -f $i)
$flBytes += ,([System.IO.File]::ReadAllBytes($path))
}
$headerSize = 4 + $flCount * 8
$ms = New-Object System.IO.MemoryStream
$bw = New-Object System.IO.BinaryWriter($ms)
$bw.Write([uint32]$flCount)
$currentOffset = $headerSize
for ($i = 0; $i -lt $flCount; $i++) {
$bw.Write([uint32]$currentOffset)
$bw.Write([uint32]$flBytes[$i].Length)
$currentOffset += $flBytes[$i].Length
}
for ($i = 0; $i -lt $flCount; $i++) {
$bw.Write($flBytes[$i])
}
[System.IO.File]::WriteAllBytes($flOutput, $ms.ToArray())
$bw.Close()
$ms.Close()
$size = (Get-Item $flOutput).Length / 1MB
Write-Host "Created forklift-bundle.jpg ($([math]::Round($size, 1)) MB)"
Write-Host "Done! Deploy both .jpg bundle files and refresh."