<?php
$filename = $argv[1];
$compression = $argv[2];
Header("Content-type: image/png");
$im = imagecreatefromgif("$filename");
$currWidth=ImageSX($im);
$currHeight=ImageSY($im);
$newWidth=$currWidth * ($compression / 100);
$newHeight=$currHeight * ($compression / 100);
$im1 = imagecreatetruecolor($newWidth,$newHeight);
$bgc = imagecolorallocate ($im1,255,255,255);
imagefilledrectangle ($im1, 0, 0, $newWidth, $newHeight, $bgc);
imagecopyresampled ($im1, $im, 0, 0, 0, 0,
$newWidth, $newHeight, $currWidth, $currHeight);
imagepng($im1);
imagedestroy($im1);
?>