473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

imagecreatefrom jpeg 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 imagecreatefrom jpeg() 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 14947
steve park wrote:


The error is coming when the class calls the imagecreatefrom jpeg() 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 imagecreatefrom jpeg() 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.andyhsoftwa re.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 imagecreatetrue color)

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.andyhsoftwa re.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_lim it", "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
2240
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 than width) images, it fails to create a resource. What the hell is it doing?
4
21600
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 thumbnails of larger pictures. recently, I upgraded my system from suse 8.2 to suse 9.0, so I assume my php/apache rpms were upgraded in the...
2
3994
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 Cancelled" page. The memory_limit for PHP has been changed to 30MB so that's not the problem. I know that the line with imagecreatefromjpeg() is...
2
11035
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? Is imagecreatefromjpeg particularly memory hungry? Immediately prior to the failure memory is given as 2405072 The jpeg being uploaded is 812201 in...
1
4420
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 to allocate 4800 bytes). I read that I should increase the memory allowed php. Not sure. This script works fine on a Windows 2000/Apache/php4...
2
662
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 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...
6
2796
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 stops running cold If using Konqueror you get the message "An error occurred while processing http://www.blah.com/tools/app"
5
3331
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 = imagecreatefromjpeg("DisplayImage.php?imageId=".$this->mImage->GetImageId()); Specifically it cant sopen that file. DisplayImage.php is pretty simple, it...
4
2485
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
2940
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 there is a file with an apostrophe in it the GD function @ImageCreateFromJPEG fails. anyone knows this problem and possible workarounds? thank...
0
7507
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7794
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
1922
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.