Jump to content

Image resizing error


teebo

Recommended Posts

Hi everyone,

 

I have a simple script that resizes a JPG image and it seems that when the resolution (not the weight!) of the image is greater than 2000 x 1500, I get an annoying server error 500.  At first I thought it could be a memory allocation error, but I tested an image at 3MB with a resolution of 300 x 300 and it works.  Whereas the SAME image at 2200 x 1700 at 600KB fails.

 

How can this be?  Is there a way to resize an image without using imagecreatefromjpeg?

 

Here is my script:

 

$g_srcfile = 'Test.jpg';

// Get new sizes
list($width, $height) = getimagesize($g_srcfile);

// Load
$thumb = imagecreatetruecolor(300, 300);
$source = imagecreatefromjpeg($g_srcfile);

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

// Output
// Content type
header('Content-type: image/jpeg');
imagejpeg($source);
die();

 

Link to comment
https://forums.phpfreaks.com/topic/46435-image-resizing-error/
Share on other sites

I just tried ini_set('memory_limit','10M');

 

Gave me:

Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 3136 bytes) in /homepages/21/d164103623/htdocs/[domain]/PixAddNew.php on line 10

 

Line 10 being: $source = imagecreatefromjpeg($g_srcfile);

Link to comment
https://forums.phpfreaks.com/topic/46435-image-resizing-error/#findComment-225869
Share on other sites

Archived

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

×
×
  • Create New...

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.