Page 1 of 1

PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-18T16:52:14-07:00
by Jesdisciple
CentOS 5.5
PHP 5.2.11

# httpd -version
Server version: Apache/2.2.14 (Unix)
Server built: Oct 27 2009 16:32:50
Cpanel::Easy::Apache v3.2.0 rev4801

`man libpng' identifies itself as:
libpng - Portable Network Graphics (PNG) Reference Library 1.2.10

From phpinfo():
imagick module version
  • 2.2.2
ImageMagick version Original topic: viewtopic.php?f=1&t=18302&p=70081

As explained at the above link, the following script consistently segfaults if this image is saved in the same directory and named original.png. If the image data is retrieved via getImageBlob, duplicate.png is a proper copy of original.png; otherwise, it is empty. The test case is to be run via php -f test.php:

Code: Select all

<?php

$thumb = new Imagick('original.png');
$thumb->setImageFormat('png');
//echo $thumb->getImageBlob();
$thumb->writeImage('duplicate.png');

?>

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-18T16:57:24-07:00
by fmw42
This works perfectly fine in command line on IM 6.6.8.4 Q16 Mac OSX tiger, with libpng-1.5.1

convert zc9vfo.png original.png

PNG code has been under quite a bit of change over many releases. So perhaps you need to upgrade your IM version and perhaps even your libpng or perhaps IMagick (you don't identify your IM or Imagick version). Otherwise, I would have to say it is something about your API code and I am not an API user.

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-18T17:04:45-07:00
by Jesdisciple
You caught me before I thought to grab the IM versions from phpinfo. I'll have to check whether upgrading is possible for us.

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-21T10:38:07-07:00
by Jesdisciple
We've upgraded to:
ImageMagick 6.2.8 (latest on CentOS)
imagick 3.1.0 (absolute latest)

And the issue persists. Similarly to you, I don't experience a segfault on the command-line.

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-21T10:48:49-07:00
by fmw42
version 6.2.8 is way too old (over 400 versions old). I suspect you really need to upgrade as IM has improved drastically since 6.2.8 and many bugs have been fixed. see http://www.imagemagick.org/script/binary-releases.php for current binaries or install from source.

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-21T11:14:25-07:00
by Jesdisciple
Works on Ubuntu 9.10 / imagick 3.0.1 / ImageMagick 6.5.1.

Re: PHP/Imagick: writeImage segfaults on certain PNG

Posted: 2011-03-21T13:27:08-07:00
by Jesdisciple
Upgraded to 6.6.8 on CentOS 5.5, still broken. What configurations might I check?