Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coalesceImages doesn't work properly with some animated gifs #2

Open
Godefroy opened this issue Nov 7, 2013 · 1 comment
Open

coalesceImages doesn't work properly with some animated gifs #2

Godefroy opened this issue Nov 7, 2013 · 1 comment

Comments

@Godefroy
Copy link

Godefroy commented Nov 7, 2013

Hi,

I encountered a bug in coalesceImages with some animated gifs. No problem with Imagick.

Here is my test code:

$image = new Gmagick();
$image->readImageBlob($object->getData());
if($image->getNumberImages() > 1){
    $image = $image->coalesceImages();
    do {
        $frame = $image->current();
        $frame->cropThumbnailImage($width, $height);
        $frame->setCompressionQuality(85);
    }while($image->nextImage());
    $image = $image->deconstructimages();

}else{
    $image->cropThumbnailImage($width, $height);
    $image->setCompressionQuality(85);
}
echo $image->getImagesBlob();

And here is an image for test:
Image
(sorry, I randomly picked an image from a blog)

If I try to crop it with $width=400 and $height=400:
Image 400x400

@Danack
Copy link
Contributor

Danack commented Dec 30, 2015

Trying to investigate this issue leads to a segfault:

$width = 50;
$height = 50;

$image = new Gmagick("./testGif.gif");
$image = $image->coalesceImages();

do {
    $frame = $image->current();
    $frame->cropThumbnailImage($width, $height);
    $frame->setCompressionQuality(85);
} 
while($image->nextImage());

$image = $image->deconstructimages();
$image->writeImages("./output.gif");
==20240== Invalid read of size 8
==20240==    at 0xC8AE26A: zim_gmagick_deconstructimages (gmagick_methods.c:706)
==20240==    by 0x601997: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==20240==    by 0x5CB52F: execute_ex (zend_vm_execute.h:417)
==20240==    by 0x61BB32: zend_execute (zend_vm_execute.h:458)
==20240==    by 0x58DF26: zend_execute_scripts (zend.c:1428)
==20240==    by 0x5326B7: php_execute_script (main.c:2471)
==20240==    by 0x61FBE0: do_cli (php_cli.c:974)
==20240==    by 0x620305: main (php_cli.c:1345)
==20240==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants