Forum Moderators: coopster

Message Too Old, No Replies

PHP Image File Size and Resize Issue

         

username

10:57 am on Jul 26, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi all,

I am developing a file upload facilty and am running into some trouble with the file size in bytes of the image being uploaded to the server. My uploader limits the image size that can be allowed to be uploaded to 1mb, then if the file meets that condition resizes the image to a max width of 300 pixels before upload and saves the file to the server...however this does not reduce the image file size in bytes usually. I would really like to take for an example a non web formatted image, and reduce the file size to below 50k for the example size, and then be able to display a thumbnail at 10k.

If anyone has any good resource information concerning the processing of images file size, or some examples, it would be really helpful.

To sumarise I want to be able to do the following (example only):

1. Upload a 250k 640x480 pixel jpg
2. Resize the image to a smaller size eg. 300x240
3. Reduce file size as much as possible
4. Save to server 300x240 version, and if applicable a thumbnail version, unless it is easier to generate thumbnail on runtime.

Thanks in advance.

eelixduppy

4:11 pm on Jul 26, 2008 (gmt 0)



The filesize should definitely be getting smaller as you reduce its size so I'm not sure what is going on for you. If you would like a pre-written script, I'm sure you can find a solution at one of the script repositories online, such as [phpclasses.org...] . This is a relatively simple script to write, however, if you are up to improving what you already have.