Problem uploading and resizing images

See all posts Reply

Problem uploading and resizing images new!
by Denzil, 16 years, 8 months ago
Hi

I am having problems resizing images. I am using WAMP 5, with PHP ver 5.2.5 and have enabled gd support.

GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.9
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled


My form is as follows and calls the image_uploader.php script:
<form enctype="multipart/form-data" action="image_uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="8000000" />
File: <input name="uploadedfile" type="file" size="50"/><br />
<input type="submit" value="Upload File" />
</form>


image_uploader.php script:
include('class.upload.php');
$handle = new upload($_FILES['uploadedfile']);
if ($handle->uploaded) {
   $handle->file_new_name_body   = 'image_resized';
   $handle->image_x              = 100;
   $handle->image_ratio_y        = true;
   $handle->image_resize         = true;
   $handle->Process('/wamp/www/test/');

   if ($handle->processed) {
      echo 'image resized';
      $handle->clean();
   } else {
      echo 'error : ' . $handle->error;
      }
  }

When I remove the $handle->image_resize = true; line from the above code the image file is uploaded to the destination directory above with the original dimensions. However, when image_resize is set to true as above, the image file is not uploaded at all.

Any ideas...? Thanks very muchReply
Re: Problem uploading and resizing images new!
by colin, 16 years, 8 months ago
Does it give you any error when it fails? Or do you get a blank screen?

How big is the image you are trying to resize? Does it work with smaller pictures?

Can you paste here the log from the class when resizing fails?Reply
Re: Problem uploading and resizing images new!
by Denzil, 16 years, 8 months ago
Hi Colin,

This may sound like a silly question, but where can I find the log from the class?

I did check the php_error.log and there are no entries in it.

The apache access.log has the following entries:
127.0.0.1 - - [24/Mar/2008:20:35:40 +0200] "GET /sam.css HTTP/1.1" 200 2836
127.0.0.1 - - [24/Mar/2008:20:35:48 +0200] "GET /upload_images.php?web_ref=300129883 HTTP/1.1" 200 798
127.0.0.1 - - [24/Mar/2008:20:35:54 +0200] "POST /image_uploader.php HTTP/1.1" 200 138


When I execute the code above, I don't get any error message, but just see a blank screen. I have tried with smaller images as well, but have the same problem.

ThanksReply
Re: Problem uploading and resizing images new!
by colin, 16 years, 8 months ago
You can get the log of the class with:
echo $handle->log;

As for the Apache logs, look into error.log

This said, it looks like a memory error to me, or maybe a defective GD.Reply
Re: Problem uploading and resizing images new!
by Denzil, 16 years, 8 months ago
Hi Colin,

Thank you so much for your advice, I made the following changes to my php.ini file:
upload_max_filesize = 64M
memory_limit = 64M
post_max_size = 64M


After restarting PHP and the trying to upload and resize images, it worked perfectly- with dimensions as high as 2816x2112. It definitely appeared to be that an insufficient memory limit was enabled in PHP.

Thanks once again for your help.

Congrats and thanks for this brilliant Class- it is definitely the best file/image uploading and resizing class that I have worked with and really easy to use.Reply
Re: Problem uploading and resizing images new!
by colin, 16 years, 8 months ago
You probably need to change only memory_limit in php.ini.Reply