Allowed memory size 134217728 bytes exhausted (tried to allocate 18472 bytes)
I am getting the above error on this line:
imagefill($canvas, 0, 0, imagecolorallocate($canvas, 255, 255, 255));
The script works fine with all types of images, but it crashes with images larger than 4000 x 3000 pixels. The image itself is only 500KB. Here's the whole code:
$canvas = imagecreatetruecolor(imagesx($source), imagesy($source));
imagefill($canvas, 0, 0, imagecolorallocate($canvas, 255, 255, 255));
imagealphablending($canvas, TRUE);
imagecopy($canvas, $source, 0, 0, 0, 0, imagesx($source), imagesy($source));
imagedestroy($source);
$quality = 100; // 0 = worst / smaller file, 100 = better / bigger file
imagejpeg($canvas, $strPath.$p_Id.".jpg", $quality); //----- save image
ImageDestroy($canvas);
+3
source to share
3 answers