Re: imagecreatefromjpeg() uses too much memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You didn't say, but, I assume that ordinary users will not be uploading to your web hotel. Thus....

To cope with the file size you must preprocess your images in an image editor, [e.g., PhotoShop, PaintShop Pro, etc.].
Enhance and compress as necessary. In general, it is best to use an image editor so you can visually judge the quality at each step.

Are the images going to be displayed on your site? If so, I can't imagine needing anywhere near 16mb for a quality rendering.

In general, GD2 does a poor job of processing quality images.  It's great for annotating and applying borders, etc.

Imagemagick is far superior for image processing.

Then


Fredrik Enestad wrote:
Hi!

I'm making a function for uploading and resizing images to my web hotel.
Problem is, memory_limit is set to 16M so when uploading larger images the
script crashes.

So, I tried to override the memory_limit setting, but as it turns out, my
web host has set some safe mode setting,
so that no settings can be changed in the php.ini, and they wont change the
setting to a higher value themselves.

This is were the code crashes:

$image_p = imagecreatetruecolor($widthNew, $heightNew);
if($mime=="image/jpeg" || $mime=="image/pjpeg") {
  $image = imagecreatefromjpeg($imgarray["tmp_name"]);
  imagecopyresampled($image_p, $image, 0, 0, 0, 0, $widthNew, $heightNew,
$widthOrg, $heightOrg);
  imagejpeg($image_p, $save_dir.$temp_filename, 80);
  return "Done";
}

The line $image = imagecreatefromjpeg($imgarray["tmp_name"]); causes the
problem.

Do any of you know any other way to solve this problem?

--
Thanks
Fredrik


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux