imagecreatetruecolor halts with no error
Posted: Tue Dec 22, 2009 1:49 pm
Folks,
I've got some code that, eventually, will resample a JPG to a new size. I'm finding however that my code is halting without error at my imagecreatetruecolor call.
My source image (though seemingly not involved at this point of the code), is 600px wide by 900px tall. My requested width and height are a proportional 480px by 720px. My output shows the "about to..." message but displays neither the die message nor the "after..." message. Here's the kicker. If my width is <= 280px, I get the "after..." message and eventually the image is resampled image is created without problems. It's only when the width is > 280 that imagecreatetruecolor fails silently.
The code to do the image resampling is in a function, in a class, tucked in a library I authored and include in my path. I found that upping the memory limit at the top of the function that does the resampling solves the problem. It really doesn't seem like so much memory would be consumed for my images, but I guess one should always do some memory checks when things like this start happening. I use the Zend AutoLoader, and I imagine there's a lot of memory consumed just loading PHP code. By the time my image resampling code comes along, there may not be much left.
Word to the wise. memory_get_usage() is your friend in times like this.
HH.
I've got some code that, eventually, will resample a JPG to a new size. I'm finding however that my code is halting without error at my imagecreatetruecolor call.
Code: Select all
echo "about to imagecreatetruecolor with $reqWidth, $reqHeight";
// create a new image for the result
$destImgResource = imagecreatetruecolor( $reqWidth, $reqHeight )
or die( "imagecreatetruecolor $reqWidth, $reqHeight failed." );
echo "after imagecreatetruecolor";
The code to do the image resampling is in a function, in a class, tucked in a library I authored and include in my path. I found that upping the memory limit at the top of the function that does the resampling solves the problem. It really doesn't seem like so much memory would be consumed for my images, but I guess one should always do some memory checks when things like this start happening. I use the Zend AutoLoader, and I imagine there's a lot of memory consumed just loading PHP code. By the time my image resampling code comes along, there may not be much left.
Word to the wise. memory_get_usage() is your friend in times like this.
HH.