3.7 trillion pictures Why can't I use the Imagecreatefromjpeg function
Image upload to generate thumbnails, use the following code
$IMGSRC = ' e:/123.jpg ';
$w 1 = getimagesize ($IMGSRC);
$SRC =imagecreatefromjpeg (IMGSRC);//Imagecreatefromjpeg ($IMGSRC);
$DST = Imagecreatetruecolor ($x, $y);
Imagecopyresampled ($DST, $SRC, 0,0,0,0, $x, $y, $w 1[0], $w 1[1]);
Imagejpeg ($DST, $IMGSRC, 80);
When the picture is less than 2M is useful, no problem. But when I upload a 3.7 trillion picture, the program will appear blank when it goes to Imagecreatefromjpeg, and the code behind will not be executed. Is there any way to resolve this issue, or directly change the image size when uploading.
------Solution--------------------
Not enough memory, huh?
The condition that determines whether GD can run normally is not the size of the picture file, but the number of dots in the picture.
When processing a picture, GD expands the picture into a bitmap in memory at a size of 8 bytes per pixel.
------Solution--------------------
It ' s an out-of-memory issue. I don ' t know if there's a formula, but it seems to happen with images that is large or high-resolution. Changing the memory in php.ini might work, up to a point. After trying 768MB I gave up and use ImageMagick now.
Please try to use code ini_set (' Memory_limit ', ' 768MB ') before process image.