Page 1 of 1

cropImage fail / internal server error

Posted: 2012-12-20T10:42:01-07:00
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

Re: cropImage fail / internal server error

Posted: 2012-12-20T11:07:00-07:00
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.

Re: cropImage fail / internal server error

Posted: 2012-12-20T11:11:34-07:00
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.

Re: cropImage fail / internal server error

Posted: 2012-12-20T11:46:24-07:00
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>";