I've got some code that auto-generates thumbnails. It works fine on my local system, but on my online site larger images (ca. 1mb and bigger) often throw errors like the following:
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /hermes/web07d/b1074/moo.nathanaelculver/accardi/canon/layout.php on line 88
My actual code looks like this:
<?php
$img = imagecreatefromjpeg( $imagefile );
$width = imagesx( $img );
$height = imagesy( $img );
$new_height = $thumbHeight;
$new_width = floor ( ($thumbHeight / $height) * $width );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, $thumbdir.basename($imagefile));
imagedestroy( $tmp_img );
?>
I presume I'm bumping into memory limits. Any way around this? Unfortunately, a large portion of the images on my site are a meg or more in size.
[EDIT: Found the other error message. Also reformatted message for clarity.]
Fatal error: Allowed memory size of 18874368 bytes exhausted (tried to allocate 14720 bytes) in /hermes/web07d/b1074/moo.nathanaelculver/accardi/site/Themes/Board-n-Parchment/layout.php on line 173
Line 173 is
$img = imagecreatefromjpeg( $imagefile );
--Nathanael