What is the maximum width and height that ImageCopyResampled can handle? My code works for smaller images in terms of width and height. For larger images, it will disregard the coordinates, meaning the cropping starts from the upper left corner of the image.
Is there a workaround? Here's a portion:
$trgt_width = 500;
$trgt_height = 400;
if(copy($src_file, $trgt_file)):
$src_image = imageCreateFromJpeg($src_file);
$trgt_image = imageCreateTrueColor($trgt_width, $trgt_height);
imageCopyResampled($trgt_image, $src_image, 0, 0, $x, $y, $trgt_width, $trgt_height, $width ,$height);
imageJpeg($trgt_image, $thumb_file, 75);
endif;
Thanks.
It depends on the maximum amount of RAM your scripts may occupy. This is usually set on your server by the administrator. The setting is called memory_limit
You can find it out using phpinfo()
and searching for "memory_limit".
A rough calculation on the size needed to resize an image:
number of bytes width x number of bytes height x 3
3 for each channel of a true color image: Red, Green and blue.
So, an image 1000 x 1000 Pixels in size will take up at least 3 MB of memory. Probably more during the resize process, because the function will have to keep both the large and the resized version in memory at the same time.
In your case though, I would suspect that the image does not get cropped at all, probably because the copy operation fails because $src_file
does not exist at all.