Jump to content


Photo

imagecopyresampled() size limitation?


  • Please log in to reply
5 replies to this topic

#1 mr_sarge

mr_sarge
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 25 February 2006 - 03:54 PM

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);


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 25 February 2006 - 08:31 PM

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.

#3 mr_sarge

mr_sarge
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 25 February 2006 - 09:06 PM

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:

Header
Menu
PHP SCRIPT TO RESIZE
PHP SCRIPT THAT CONFIRM THAT ALL IS OK
some link
footer

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 !!

#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 25 February 2006 - 09:09 PM

[!--quoteo(post=349366:date=Feb 25 2006, 03:31 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Feb 25 2006, 03:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What exact error are you getting?
[/quote]

Turn on error reporting if necessary:

ini_set("error_reporting", "1");
ini_set("display_errors", "E_ALL");


#5 mr_sarge

mr_sarge
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 25 February 2006 - 09:14 PM

nothing is display with this code on when I upload a big file...

#6 Crew-Portal

Crew-Portal
  • Members
  • PipPipPip
  • Advanced Member
  • 516 posts
  • LocationWinnipeg

Posted 02 May 2008 - 06:48 PM

wow this topic sure is OLD. But sadly its still unsolved!  ;D

logo.png

 

PHP: 5.5.6 | MySQL: 5.6.14 | Operating System: Windows 7[64BIT] | Display: 2x47in 1920x1080p Sony Bravia (Extended Display) | Browser: Mozilla Firefox 27





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users