php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25919 Sometimes imagecreatefromjpeg stops
Submitted: 2003-10-20 06:35 UTC Modified: 2004-08-10 23:13 UTC
From: agnermadsen at hotmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.3 OS: FreeBSD
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: agnermadsen at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-10-20 06:35 UTC] agnermadsen at hotmail dot com
Description:
------------
If the file size of the JPEG-file is over 400kb then imagecreatefromjpeg() sometimes crashes and sometimes it's when it reaches imagecreatetruecolor();

Reproduce code:
---------------
$width=650;
$im = @imagecreatefromjpeg($pic);
$size=getimagesize ($pic );
$height=intval($width/$size[0]*$size[1]);
if ($height<$width/$size[0]*$size[1]) $height++;
$picre=@imagecreatetruecolor($width,$height);
imagecopyresampled (  $picre,$im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagejpeg($picre);
imagedestroy($picre);
imagedestroy($im);

Expected result:
----------------
Made a new picture.

Actual result:
--------------
Nothing

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-20 06:41 UTC] sniper@php.net
What is the configure line you used to configure PHP?
If you didn't use the bundled GD library, bogus this report yourself..

 [2003-10-23 03:47 UTC] agnermadsen at hotmail dot com
Configure: 
'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all' '--with-regex=php' '--disable-cli' '--with-apxs=/usr/local/sbin/apxs' '--with-bz2=/usr' '--enable-ctype' '--enable-exif' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-xpm-dir=/usr/local' '--with-imap=/usr/local' '--with-imap-ssl=/usr/local' '--with-mcrypt=/usr/local' '--with-mysql=/usr/local' '--enable-overload' '--with-pcre-regex=yes' '--enable-posix' '--enable-session' '--enable-sockets' '--enable-tokenizer' '--enable-xml' '--with-expat-dir=/usr/local' '--with-zlib=yes' '--prefix=/usr/local' 'i386-portbld-freebsd4.8'
 [2003-10-23 22:24 UTC] iliaa@php.net
What is your memory limit set to? You are probably reaching the memory limit and PHP terminates.
 [2003-10-24 05:40 UTC] agnermadsen at hotmail dot com
memory_limit 8M

http://www.ringsborg-madsen.dk/nytsite/phpinfo.php
 [2003-10-28 10:38 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

It is quite likely you are reaching the memory limit and PHP terminates. Image manipulation is a very memory intensive process. I'd suggest raising the memory limit higher to something like 20 megabytes.
 [2004-08-10 23:08 UTC] stemplar444 at yahoo dot com
My server hang, when the images contained more than 1'609'092 pixels. It was not a question of file size.

I found this bug report and corrected my memory settings accordingly to fix this behavior.

However, I disagree with iliaa@php.net, that this is no bug. In my opinion, proper API providers have to have a proper error handling. 

So in this case, the GD library or PHP needs to check for enough memory while executing a function.

And since this is so well known, such an error handling would maybe prevent all those bogus bug reports in this area.

simon.
 [2004-08-10 23:13 UTC] pajoye@php.net
> And since this is so well known, such an error
> handling would maybe prevent all those bogus 
> bug reports in this area.

And if everyone works with a proper error reporting mode and reads the logs, they may know what's going on.

Nothing more can be done, the memory allocation is done by PHP (as near all allocations), the error is reported by PHP itself.

--Pierre
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 04:01:29 2024 UTC