Resizing images - images too big?

See all posts Reply

Resizing images - images too big? new!
by Ken, 16 years ago
I'm trying to resize and crop images class.upload.php and it's working fine with small images (say, 20k or 30k) but it's not letting me upload larger images, even on my localhost. I've tried setting file_max_size and the ini mem limit to 20M but to no avail.Reply
Re: Resizing images - images too big? new!
by colin, 16 years ago
20MB is not a lot at all if you want to process images. Also, the size of the image is not important; only the dimensions in pixels are relevant, as the image is uncompressed as bitmap in memory.

What are the errors that you get?Reply
Re: Resizing images - images too big? new!
by Ken, 15 years, 12 months ago
It's not returning any errors unfortunately; I've tried debugging it but to no avail. Even if I don't crop the larger images, if I just refer to them as images (i.e. if I instantiate image_resize=true) it also crashes. It seems like the script just doesn't like the larger images - they're all RGB Jpeg's. *confused*Reply
Re: Resizing images - images too big? new!
by Ken, 15 years, 12 months ago
If this is any help, this is the script I'm using:

$handle = new upload("../temp_photos/mytest.jpg");
$handle->file_max_size='10240000';
if ($handle->uploaded) {
  $handle->image_crop = array(10,30,60,20);
  $handle->process("../temp_photos/");
  if ($handle->processed) {
    echo 'image cropped';
    $handle->clean();
  } else {
    echo 'error : ' . $handle->error;
  }
}
Reply
Re: Resizing images - images too big? new!
by colin, 15 years, 12 months ago
Your code is correct.

It is almost certainly a memory issue. Check with a phpinfo() that you indeed have raised the memory limits. Also try, just for the sake of testing, to have a lot of memory available (100+MB, rather than 20 or 32).Reply
Re: Resizing images - images too big? new!
by Bruno Chavez, 15 years, 11 months ago
Hi!!

I have the same problem, I work with local files, I uploaded with a perl cgi that I wrote, because my server is so limited in time limit, then when I process a small image, works really fine, but when I process 1MB > crash... don't tell anything, any error, simply when execute $handle->Process('../img/Thumbs1/'); don't continue... break...

Can you help me... my code is:

$handle = new Upload('../img/cuadros/' . $Archivo);
$handle->file_max_size='10240000';
if ($handle->uploaded) {
  $handle->image_convert         = 'jpg';
  $handle->image_resize            = true;
  $handle->image_ratio_y           = true;
  $handle->image_ratio_x           = true;
  $handle->image_x                 = 580;
  $handle->image_y                 = 460;
  $handle->Process('../img/Thumbs1/');
  if ($handle->processed) {
    rename('../img/Thumbs1/' . $handle->file_dst_name, '../img/Thumbs1/' . $ArchivoFin); 
  }
  $handle-> Clean();
}

please I need it...

Regards
Bruno ChávezReply
Re: Resizing images - images too big? new!
by colin, 15 years, 11 months ago
Check the posts above. You are running out of memory. See this thread

Try to raise your local memory to 20M, 32M or more.

You can add this in your script:
ini_set ( "memory_limit", "20M")

Or in a .htaccess file:
php_value memory_limit 20M
Reply
Re: Resizing images - images too big? new!
by Ravan, 13 years, 6 months ago
My image is 3264x2448 and my php memory limit is 64M and it still doesn't work. why?Reply
Re: Resizing images - images too big? new!
by colin, 13 years, 6 months ago
3264x2448 = 7 990 272 ~= 8Mpixels
8M * 8 bits = 64Mbytes

So with this picture, just to load it in memory, you a reaching your memory limit. Your application probably use some memory too, and if you do processing on the image, you need more memory.Reply
Re: Resizing images - images too big? new!
by Amlana, 15 years, 11 months ago
You should check the mega pixcel of the image.
If your GD Library support this then it must resize image.Reply
Re: Resizing images - images too big? new!
by Ravan, 13 years, 6 months ago
How can I check this?
My GD info is:
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.10
WBMP Support enabled
XPM Support enabled
XBM Support enabled


and the mega pixcel i think it calculated by multiplying px width with px height,
3264x2448 = 7990272 ( 7 mega pixcel ? )Reply