Reply to Re: imagecreatefromjpeg problem

Your name:

Reply:


Posted by Andy Hassall on 11/11/60 11:19

On Tue, 21 Jun 2005 16:21:19 -0500, bernie <bernie@bernieberg.com> wrote:

>I have an image upload and resize script that I have used on a number of
>servers with no issues. I have now use it in a new app that I uploaded
>to a new server. I worked fine on my dev server, but when I submit the
>POST form to the page that does the resizing the page grids it gears for
>a while, then just quits. It is frustrating because I don't get any
>errors. The image does upload, but nothing seems to happen after that.
> I think I have boiled it down the the "imagecreatefromjpeg" function.
> If I comment it out I finally get an error (that relates to it being
>commented out). I have also found out that the script works fine with
>smaller images (50k or so seems to work), but not with larger images
>(600k or so).

OK, this points straight to memory_limit being enabled. A 600k JPEG will
decompress to several megabytes of raw image data in memory.

>It seems to be a problem with the server setup, as it works fine on my
>dev server. phpinfo() gives some standard info. It is php 4.3.8 on
>freebsd.
>
>Here is the function: If you think more of the code would be helpful
>please let me know, I'll post it.
>
>
>function resize_jpg($img,$img2,$w,$h){
> $imagedata = getimagesize($img);
> if ($w && ($imagedata[0] < $imagedata[1])) {
> $w = ($h / $imagedata[1]) * $imagedata[0];
> } else {
> $h = ($w / $imagedata[0]) * $imagedata[1];
> }
> $im2 = imagecreatetruecolor($w,$h);
> $image = imagecreatefromjpeg($img); //this is the line that causes
>problems

You may well have enough memory for the first image, then you run out on the
second.

Check what memory_limit is set to in php.ini.

http://uk2.php.net/manual/en/ini.core.php#ini.memory-limit

You might be able to override it to a higher value.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация