Jump to content


This topic is now archived and is closed to further replies.


imagecopyresampled() size limitation?

Recommended Posts

I have this simple code that I've found in the php manuel to resize image. I work great, but if the image is too big, script crash and wont resize the image. I have set a limit to 1280x1024 since all that is bigger than this crash.

I don't know if it's the image file size in kb or it's dimension, but what can I do?

// Get new sizes for thumb
list($width, $height) = getimagesize($prod_img);
$newwidth = "200";
$newheight = "150";

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($prod_img);

// Resize
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb, $prod_img_thumb);

Share this post

Link to post
Share on other sites
What exact error are you getting?

Offhand, it could be a couple of things...

1. The file you are uploading is too big and doesn't get uploaded. By default, the limit is set to 2048kb.

2. The script is using too much memory. I've encountered this before when working with very large jpgraph graphs. By default a script is limited to occupying 8MB (maybe 16, but I think 8) of memory, if you have a very large pic, then as it's doing it's resizing functions on it, it may be going above that.

Share this post

Link to post
Share on other sites
the file that I am trying to upload and resize is 900kb 2272x1704

the file is uploaded, I can see it and open it on the server manually.

When the scrypt try to resize it, notting append. the html page that I should see with a "correct" confirmation is not display.

My page is look this:

some link

Is image is less than 500kb all of this is ok. If I try my 900kb image, html page stop after the menu part. my link and footer are not displayed and in the source, tha table aren't close !!

Share this post

Link to post
Share on other sites
[!--quoteo(post=349366:date=Feb 25 2006, 03:31 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Feb 25 2006, 03:31 PM) [snapback]349366[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What exact error are you getting?

Turn on error reporting if necessary:

[code]ini_set("error_reporting", "1");
ini_set("display_errors", "E_ALL");[/code]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.