PowerShell
PowerShell
Compress Bytes
See more Compression Examples
Demonstrates how to compress binary data.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$fac = New-Object Chilkat.FileAccess
$fileBytes = $fac.ReadEntireFile("qa_data/bmp/big.bmp")
if ($fac.LastMethodSuccess -ne $true) {
$($fac.LastErrorText)
exit
}
$compress = New-Object Chilkat.Compression
$compress.Algorithm = "deflate"
$compressedBytes = $compress.CompressBytes($fileBytes)
if ($compress.LastMethodSuccess -ne $true) {
$($compress.LastErrorText)
exit
}
$success = $fac.WriteEntireFile("qa_output/compressedBmp.dat",$compressedBytes)
if ($fac.LastMethodSuccess -ne $true) {
$($fac.LastErrorText)
exit
}