php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42656 crash imagecreatefromjpeg specific php 5.2.4
Submitted: 2007-09-13 11:45 UTC Modified: 2013-01-08 07:20 UTC
Votes:15
Avg. Score:4.0 ± 1.0
Reproduced:11 of 13 (84.6%)
Same Version:8 (72.7%)
Same OS:3 (27.3%)
From: jeanpascal dot leandre at free dot fr Assigned: pajoye (profile)
Status: No Feedback Package: Reproducible crash
PHP Version: 5.2.4 OS: Windows server 2003
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-09-13 11:45 UTC] jeanpascal dot leandre at free dot fr
Description:
------------
Imagecreatefromjpeg crash with large-sized pictures (ex 2 Megapixel 500KB) since php version 5.2.1. The probleme exists width php 5.2.3, 5.2.4 there, but did not exist php 5.2.0 there.

The increase of memory allowed for php scripts do not solve the problem. If 8M memory is enough for a picture of 6 Megapixel width php 5.2.0, even 32M of memory is not enough for PHP 5.2.4 , because memory occupation of the server becomes then very very important(my server has only 2 GB DDR)

The problem declared itself during the upgrade 5.2.1. It is thus necessary to see what took place during the programming of 5.2.1

Reproduce code:
---------------
$conf    = $_GET["conf"];
$fichier = $_GET["fichier"] ;
include("sys/".$conf.".php");

$image  = ImageCreateFromJPEG($fichier) ;
$width  = imagesx($image) ;
$height = imagesy($image) ;
$ratio  = $width / $height ;

$new_width  = $widthThumb ; 
$new_height = $widthThumb / $ratio ;
if ($new_height > $heightThumb) 
{
  $new_height = $heightThumb ;
  $new_width  = $heightThumb * $ratio ;
}

$thumb = imagecreatetruecolor($new_width,$new_height) ;
imagecopyresampled($thumb,$image,0,0,0,0,$new_width,$new_height,$width,$height) ;
header("Content-type:image/jpeg") ;
imagejpeg($thumb) ;
imagedestroy($image) ;
imagedestroy($thumb) ;

Expected result:
----------------
This script work normally with the large-sized pictures of several megapixels from the new digital cameras

Actual result:
--------------
crash with large-sized pictures

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-13 12:03 UTC] pajoye@php.net
Nothing has been changed in imagecreatefromjpeg. Are you sure it crashes and it is not a memory_limit (be sure to have error_reporting and display errors On)?

If yes, please try again with the memory_limit disabled.

However, it looks like a memory limit problem. PHP's memory manager has been changed since 5.2.0. The reported memory usage is higher than in 5.2.0 (it does not use more but the reports/calculation is more accurate).

If you still experiment the crash, please provide a link to an image you used.



 [2007-09-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-08-18 12:33 UTC] dhanraj dot r at indianic dot com
Your vote system is wrong one person can voted the more time in this system so how can u stop it
 [2009-03-01 22:13 UTC] megazzt at gmail dot com
I have a similar issue.  When I try to load a very large image using 
imagecreatefrom*, script execution halts and any content that has not 
been flushed will not be sent to the user.  There is more than enough 
memory to handle the image.

I have reproduced this by creating a simple 5000x5000 transparent 24-
bit PNG in Irfanview (PNG compression at maximum).

I am using Windows XP SP3, PHP 5.2.8, Apache 2.2.11.  No errors in 
the Apache error log.  It was using the php5apache2 module (instead 
of the php5apache2_2 one) but changing it didn't affect my problem.
 [2009-03-01 22:23 UTC] pajoye@php.net
Provide a link to the images causing issues then.
 [2009-03-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-04-14 14:44 UTC] pajoye@php.net
-Status: No Feedback +Status: Feedback
 [2010-04-14 14:44 UTC] pajoye@php.net
The image you send works here, no warning and can the resulting GD resource is perfectly valid.

Please send me another one, if you have any. Also try using a recent PHP version (5.2.13).
 [2013-01-08 07:20 UTC] pajoye@php.net
-Status: Feedback +Status: No Feedback
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 09:01:29 2024 UTC