cropImage produce different results for PNG and GIF format
Posted: 2009-05-11T15:22:15-07:00
Sample image: http://palmzlib.sourceforge.net/images/plogo.png
when you crop the image and output it as PNG and GIF, you get different results. PNG has the correct crop width and height, GIF still keeps the original canvas size, but shifts the cropped image.
Note that crop is done from (20, 0) in the example
Output PNG:
Output GIF:
when you crop the image and output it as PNG and GIF, you get different results. PNG has the correct crop width and height, GIF still keeps the original canvas size, but shifts the cropped image.
Note that crop is done from (20, 0) in the example
Output PNG:
Code: Select all
<?php
$im = new Imagick('plogo.png');
$crop_w = 80;
$crop_h = 120;
$x = 20;
$y = 0;
$im->cropImage($crop_w, $crop_h, $x, $y);
$im->setImageFormat('png');
header('Content-Type: image/png');
echo $im;
?>
Code: Select all
<?php
//$im = new Imagick('stock.png');
$im = new Imagick('plogo.png');
$crop_w = 80;
$crop_h = 120;
$x = 20;
$y = 0;
$im->cropImage($crop_w, $crop_h, $x, $y);
$im->setImageFormat('gif');
header('Content-Type: image/gif');
echo $im;
?>