cropImage fail / internal server error

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
bluecomet
Posts: 2
Joined: 2012-12-19T17:03:15-07:00
Authentication code: 6789

cropImage fail / internal server error

Post by bluecomet »

Have been troubleshooting a Hostpapa account which fails when Wordpress 3.5 attempts to crop media uploads to create thumbnails. I dug into wordpress code and reproduced the problem outside of Wordpress, as follows:

Doing a queryFormats call causes cropImage to fail. Either with just a blank screen, or internal server error or a memory error if the file is large. Leaving it out will work, even on large images.

< ? php

/* This line below will cause the cropImage to fail */
Imagick::queryFormats( 'JPG');

$img = new Imagick('leonids.jpg');
$img->writeImage('testresult16.jpg');
$img->cropImage(150,150,0,0);
$img->writeImage('testresult16-crop.jpg');

? >

Any thoughts appreciated.

Version is ImageMagick 6.4.8 2011-02-03 Q16
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: cropImage fail / internal server error

Post by Bonzo »

a/ If it will work OK without the line I would just remove it.
b/ According to the php Imagick site "Imagick::queryFormats — Returns formats supported by Imagick" so it may be being used incorrectly?
c/ Imagick is not written or maintained by the writers of Imagemagick and there are not many user here to help you.
bluecomet
Posts: 2
Joined: 2012-12-19T17:03:15-07:00
Authentication code: 6789

Re: cropImage fail / internal server error

Post by bluecomet »

The code is in Wordpress. I do not want to edit wordpress core files. I am trying to reproduce the problem by writing test code.

The actual line where it is in wp-includes/class-wp-image-editor-imagick.php is
return return ( (bool) Imagick::queryFormats( $imagick_extension ) );

Anyway thanks for the response.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: cropImage fail / internal server error

Post by Bonzo »

I suppose that means your installation only supports jpg?

Another reason could be your version of Imagick may not support that function?

Try running this and see what you get:

Code: Select all

$info = new Imagick(); 
$formats = $info->queryFormats();
echo "<br /><b>Formats Supported:</b>";
echo "<ul>";
foreach( $formats as $key=>$value )
 { echo "<li>$value"; }
echo "</ul>";
Post Reply