(PHP ActiveX) Compress Bytes
Demonstrates how to compress binary data.
<?php
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.FileAccess')
$fac = new COM("Chilkat.FileAccess");
$fileBytes = $fac->ReadEntireFile('qa_data/bmp/big.bmp');
if ($fac->LastMethodSuccess != 1) {
print $fac->LastErrorText . "\n";
exit;
}
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Compression')
$compress = new COM("Chilkat.Compression");
$compress->Algorithm = 'deflate';
$compressedBytes = $compress->CompressBytes($fileBytes);
if ($compress->LastMethodSuccess != 1) {
print $compress->LastErrorText . "\n";
exit;
}
$success = $fac->WriteEntireFile('qa_output/compressedBmp.dat',$compressedBytes);
if ($fac->LastMethodSuccess != 1) {
print $fac->LastErrorText . "\n";
exit;
}
?>
|