PHP/Imagick: writeImage segfaults on certain PNG

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Jesdisciple
Posts: 10
Joined: 2011-03-11T14:26:57-07:00
Authentication code: 8675308

PHP/Imagick: writeImage segfaults on certain PNG

Post 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');

?>
Last edited by Jesdisciple on 2011-03-18T17:02:17-07:00, edited 5 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post 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.
Jesdisciple
Posts: 10
Joined: 2011-03-11T14:26:57-07:00
Authentication code: 8675308

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post 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.
Jesdisciple
Posts: 10
Joined: 2011-03-11T14:26:57-07:00
Authentication code: 8675308

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post 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.
Jesdisciple
Posts: 10
Joined: 2011-03-11T14:26:57-07:00
Authentication code: 8675308

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post by Jesdisciple »

Works on Ubuntu 9.10 / imagick 3.0.1 / ImageMagick 6.5.1.
Jesdisciple
Posts: 10
Joined: 2011-03-11T14:26:57-07:00
Authentication code: 8675308

Re: PHP/Imagick: writeImage segfaults on certain PNG

Post by Jesdisciple »

Upgraded to 6.6.8 on CentOS 5.5, still broken. What configurations might I check?
Post Reply