php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27636 imagecreatefromjpeg fails if the picture is too high
Submitted: 2004-03-18 12:18 UTC Modified: 2004-03-18 14:54 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mito at nic dot fi Assigned:
Status: Closed Package: GD related
PHP Version: 4.3.4 OS: FreeBSD 4.8-RELEASE #0
Private report: No CVE-ID: None
 [2004-03-18 12:18 UTC] mito at nic dot fi
Description:
------------
When calling imagecreatefromjpeg("image.jpg"); where image.jpg is 1200x1600 pixels of size it causes an internal server error with no actual error output just a plank page. I'm not sure if it's because the picture is too high or does it occur every time if the height is larger than width. I tested with many similar jpgs that were produced in same way ( same digicam ), but were 1600x1200 and it worked fine. I also tested the same code in 4.3.2 running on Windows and it worked fine with both sizes of picture.

Reproduce code:
---------------
<?php
  $im = imagecreatefromjpeg("badsanta.jpg");
  print "Done!";
?>

See it at: http://mindanao.globat.com/~hopea.net/errortest/

Expected result:
----------------
Done!

Actual result:
--------------
500 Internal system error and a blank page (in IE).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-18 12:29 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You probably have a memory_limit enabled and it is reached 
trying to allocate memory to store a big image. 
 [2004-03-18 13:18 UTC] mito at nic dot fi
That is not the case. The test pic I provided that the code works with is larger than the pic that causes the failure. Therefor if it were up to the picture being too large and using too much memory it would occur with the larger picture too wouldn't it?
 [2004-03-18 13:25 UTC] mito at nic dot fi
Image that works:
Dimensions: 1600x1200
Size on disk: 575KB

Image that doesn't work:
Dimensions: 1200x1600
Size on disk: 491KB
 [2004-03-18 13:29 UTC] pajoye@php.net
Hello,

both work perfectly here. Either using cli, or apache, php5 or php4.

Please add the memory_limit option to your php.ini. Default is 8M, try more.

pierre
 [2004-03-18 14:54 UTC] mito at nic dot fi
Well, it does work on smaller pics so I guess it is the memory limit after all. I just wonder how a smaller pic can take more memory..
 [2016-11-22 23:51 UTC] phpbugs at juracid dot co dot uk
For the confused, JPEGs are compressed, the image created by imagecreatefromjpeg() is a raw (uncompressed) one so the size will be approximately width * height * 3

That's assuming 3 bytes / 24 bits per pixel, 8-bits for each of R,G,B, in reality using width * height * 4 might be safer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 02:01:27 2024 UTC