Why doesn't the 3.7 trillion picture use the Imagecreatefromjpeg function

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.