Large images : upload works, resize not

See all posts Reply

Large images : upload works, resize not new!
by Rene, 11 years, 10 months ago
Hello,

I have some problem with the upload class.
Uploading and resize goes great. But when i have larger images to upload, for example 4MB, i got a blank page. Also $handle->log dont give than any information.

I already have set the limits to 40MB. But no positive result.
My code is :
$handle = new upload($_FILES['image'], 'nl_NL');
if ($handle->uploaded) {
  $handle->file_new_name_body      = "new_name"; 
  $handle->image_resize        = true;
  $handle->image_ratio        = true;
  $handle->image_x          = 800;
  $handle->image_y          = 600;
  $handle->process('../uploads/pages/images/large');
  
  if ($handle->processed) {
    echo 'image resized';
    $handle->clean();
  } else {
    echo 'error : ' . $handle->error;
  }

  echo $handle->log;
}

The script will work also with larger images, when i uncomment these rows :
//$handle->image_resize        = true;
//$handle->image_ratio        = true;
//$handle->image_x          = 800;
//$handle->image_y          = 600;

Then my log will work, and i see this log :

image resizedsystem information
- class version : 0.31
- operating system : Linux
- PHP version : 5.2.13
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 40M (41943040 bytes)
- language : nl_NL
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME type detected as image/jpeg by UNIX file() command
- MIME validated as image/jpeg
source variables
- You can use all these before calling process()
file_src_name : DSC01130.JPG
file_src_name_body : DSC01130
file_src_name_ext : jpg
file_src_pathname : /tmp/phpvVvkZV
file_src_mime : image/jpeg
file_src_size : 4855489 (max= 41943040)
file_src_error : 0
- source file is an image
image_src_x : 3648
image_src_y : 2736
image_src_pixels : 9980928
image_src_type : jpg
image_src_bits : 8
process file to ../uploads/pages/images/large/
- file size OK
- file mime OK : image/jpeg
- new file name body : 33_20130109112320
- file name safe format
- destination variables
file_dst_path : ../uploads/pages/images/large/
file_dst_name_body : 33_20130109112320
file_dst_name_ext : jpg
- checking for auto_rename
- destination file details
file_dst_name : 33_20130109112320.jpg
file_dst_pathname : ../uploads/pages/images/large/new_name.jpg
- new_name.jpg doesn't exist already
- no image processing wanted
- process OK
cleanup
- delete temp file /tmp/phpvVvkZV
Reply
Re: Large images : upload works, resize not new!
by colin, 11 years, 10 months ago
You are running out of memory.

Search for memory in the site, or click here.

You can also check this post.

You need to raise the PHP memory limit, usually in php.ini. On shared hosting, you probably can't edit your php.ini, so you can try the following, although it will work only if the hosting company allows it, which they usually don't.

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

Or in a .htaccess file:
php_value memory_limit 40M

If the above doesn't work, ask your hosting company.Reply
Re: Large images : upload works, resize not new!
by Rene, 11 years, 10 months ago
As i said before.. i already set the memory_limit to 40MB. but that wont work.

So i checked how much memory i need.... width * height * 8 gives me 76 MB i need.
So i changed the memory limit to 128 MB, and that works for me.

ThnxReply