473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

imagecreatefromjpeg problem

Hi everyone,

this is one of those "inherited from someone else" projects that I'm having
problems with and was wondering if someone could help me out.

Our setup:

Redhat Linux
Apache 2.0.46
PHP 4.3.2
GD 1.8.4

We have a php-based setup that allows users to upload images and then some
back-end stuff that stores the original image and creates a thumbnail image.
I've just noticed that large images, say 1500x1500 or larger, give the
resize script some problems. We're using Shiege Iseng's resize class
(http://kentung.f2o.org/scripts/thumbnail/).

The error is coming when the class calls the imagecreatefromjpeg() function,
and the specific error is

Fatal error: Allowed memory size of 29360128 bytes exhausted (tried to
allocate 8652 bytes) in <servername>/resize.php on line 51

The image itself is 2163x2957x24bpp at 300 dpi and is 3 megs on disk and
18.31 MB in memory, according to IrfanView.

If I use IrfanView to reduce the image to, say, 1400x1800 or so then the
resize script has no problems, so I guess there really IS a memory issue.
;-)

I'm wondering:

1. will the problem go away if I upgrade to GD 2.x?
2. will the problem go away if I upgrade to PHP 5?

It's doubtful that I'll be able to upgrade PHP or GD, though ...

So, first of all, has anyone run into a problem like this? Second, what are
my options? One big constraint is that the preferred solution is to let
users upload images to whatever size they want, so setting a 1500x1500
restriction before they upload isn't going to work.

Thanks!


Jul 17 '05 #1
5 14933
steve park wrote:


The error is coming when the class calls the imagecreatefromjpeg() function,
and the specific error is

Fatal error: Allowed memory size of 29360128 bytes exhausted (tried to
allocate 8652 bytes) in <servername>/resize.php on line 51


Hi Steve,

You could try to get around this by adding a line like:

ini_set("memory_limit","30M");

at the top of your script.
Upgrading PHP or GD won't solve this problem. It's just a sign that the
resize script is pretty inefficient with memory. ;)
HTH.

--
http://www.phpforums.nl
Jul 17 '05 #2
On 13 Jul 2005 18:12:10 -0400, sp***@cc.gatech.edu (steve park) wrote:
We have a php-based setup that allows users to upload images and then some
back-end stuff that stores the original image and creates a thumbnail image.
I've just noticed that large images, say 1500x1500 or larger, give the
resize script some problems. We're using Shiege Iseng's resize class
(http://kentung.f2o.org/scripts/thumbnail/).

The error is coming when the class calls the imagecreatefromjpeg() function,
and the specific error is

Fatal error: Allowed memory size of 29360128 bytes exhausted (tried to
allocate 8652 bytes) in <servername>/resize.php on line 51

The image itself is 2163x2957x24bpp at 300 dpi and is 3 megs on disk and
18.31 MB in memory, according to IrfanView.
Can you simply raise the value of memory_limit?

It's there to stop runaway scripts eating memory, but in this case you know
you need that memory for a short time to do the processing.
I'm wondering:

1. will the problem go away if I upgrade to GD 2.x?
2. will the problem go away if I upgrade to PHP 5?


Wouldn't have thought so - you're using the memory, and so memory_limit is
working as advertised.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3
i had the same problem once: i got around by NOT using true color
images, which reduces the needed memory tremendously (using
imagecreate, not imagecreatetruecolor)

2 problems with that: 1st you might already be running out of memory
just opening the uploaded image and 2nd you'd have to try if the
quality is still sufficient for the thumbs.

micha

Jul 17 '05 #4
On 13 Jul 2005 18:12:10 -0400, sp***@cc.gatech.edu (steve park) wrote:
Second, what are my options?


Another option worth mentioning is running ImageMagick instead. As an external
process, it's not subject to PHP's memory limits. And it can be faster as well.

The downside is it needs you to run an external process (or load the
ImageMagick PHP extension).

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #5
> Another option worth mentioning is running ImageMagick instead. As an external
process, it's not subject to PHP's memory limits. And it can be faster as well.


turns out that doing something like

ini_set( "memory_limit", "200M" );

has fixed the problem.

Thanks!

steve

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jn | last post by:
I'm working with images from a Kodak 2MP camera. It looks like the function will only create a resource if I give it horiznotal pictures from this camera....if I give it vertical (height larger...
4
by: Mike | last post by:
hopefully this is an easy one to solve and I'm just missing something little... basically, I had a nice little website running with php, apache, etc... that uses imagecreatefromjpeg to create...
2
by: jn | last post by:
This is the weirdest thing I've come across in a while. I'm trying to resize an image. If I give it a small image ( < 100K) it will resize. If I give it a larger image, it gives me the IE "Action...
2
by: Simon Stewart | last post by:
Has anyone else experience of imagecreatefromjpeg failing with an error message about memory even though the size of the image being uploaded is nothing like the space available to the script? ...
1
by: Olivier | last post by:
Hi, I have the following code in my php script : $fhSrc = imagecreatefromjpeg($srcFile); This cause me the following error : Fatal error: Allowed memory size of 8388608 bytes exhausted (tried...
2
by: bernie | last post by:
Howdy, 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...
6
by: comp.lang.php | last post by:
PHP version 4.3.9 GD version 2.0.2 Whenever I use imagecreatefromjpeg(), PHP completely dies. No errors, no warnings, no notices, it dies in the following manner: If using Firefox it just...
5
by: Areric | last post by:
Ok all. I have a series of images stored in a db. Im trying to work on a script that will let me scale them based on user input. Ive hit a bit of a roadblock on this line. $orig =...
4
by: jeffsnox | last post by:
Hi, I'm struggling to get imagecreatefromjpeg to work correctly. I'm running PHP 4.3.9 with GD bundled (2.0.28 compatible). If I run this: $myimage = imagecreatefromjpeg("myfilename");
1
by: tim.landgraf | last post by:
hi there, i am experiencing a strange problem. i am iterating through a given directory, selecting only jpg - images that are then resized and inserted into a database. everything works, but if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.