Click to See Complete Forum and Search --> : shrinking an image ?


DaveinLondon
12-30-2004, 05:49 AM
I don't know if this is possibilty in javascript or PHP or maybe I need the server to run a program - but this is what I'd like to do:

When some one uploads a file to the server - it maybe about 125 kb
but as the image only needs to be about 120 x 120 px I only need the quality that you'd get in a file of about 5 kb . So can I squash the file size with js or PHP or something else that I can run automatically when the file is uploaded maybe from my PHP program ?

What would you recommend that I use ?

Thanks.
David.

LiLcRaZyFuZzY
12-30-2004, 06:32 AM
http://www.php.net/manual/en/function.imagecopyresized.php


From php.net (http://www.php.net/manual/en/function.imagecopyresized.php)
int imagecopyresized ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h)

imagecopyresized() copies a rectangular portion of one image to another image. dst_image is the destination image, src_image is the source image identifier. If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.