Hi,
When cropping with PHP Imagick, some gifs that are cropped correctly with ImageMagick 6.7.7-10 have errors after cropping on server with 6.9.1-7 version installed. What could be the problem?
One of gifs causing error:
Thanks
Different gif cropping behavior between versions 6.9.1-7 and 6.7.7-10
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Different gif cropping behavior between versions 6.9.1-7 and 6.7.7-10
Please provide a command that behaves differently between the versions.
snibgo's IM pages: im.snibgo.com
Re: Different gif cropping behavior between versions 6.9.1-7 and 6.7.7-10
Here is the PHP code responsible for cropping:
--------------------------------------------------------------------
$image = new \Imagick($file->tempName);
if($file->type=="image/gif") //determine image format
{
//if it's GIF file, resize each frame
$image = $image->coalesceImages();
if ($play_once) {
$image->setimageiterations(1);
}
$i = 0;
foreach ($image as $frame) {
$frame->cropImage($image_width,$image_height,$x,$y);
$frame->setimagepage(0, 0, 0, 0);
if ($i==0) {
$preview_path = str_replace('.gif', '.png', $upload_path);
$frame->writeimage($preview_path);
}
$i++;
}
$image = $image->deconstructImages();
}
//write image to a file
return $image->writeImages($upload_path, true);
------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------
$image = new \Imagick($file->tempName);
if($file->type=="image/gif") //determine image format
{
//if it's GIF file, resize each frame
$image = $image->coalesceImages();
if ($play_once) {
$image->setimageiterations(1);
}
$i = 0;
foreach ($image as $frame) {
$frame->cropImage($image_width,$image_height,$x,$y);
$frame->setimagepage(0, 0, 0, 0);
if ($i==0) {
$preview_path = str_replace('.gif', '.png', $upload_path);
$frame->writeimage($preview_path);
}
$i++;
}
$image = $image->deconstructImages();
}
//write image to a file
return $image->writeImages($upload_path, true);
------------------------------------------------------------------------------------------------------------------------------------------------------------
Re: Different gif cropping behavior between versions 6.9.1-7 and 6.7.7-10
There is a bug in the gif writer that will be resolved in 6.9.1-8.