Hi all,
As long as a graphics toolkit is installed, is it possible to resize an image that is passed to an upload script prior to actually uploading it? Meaning, is it possible to take the file from the $_FILES array, read the height/width, resize it, and then process the upload? What I'm wanting to do is take an uploaded file, compare it to a predetermined width/height and resize it to said values if the image is not already that size.

TIA!

    Well, apart from the fact that you can't do anything with the file until it has been uploaded, the answer is yes.

    Before doing anything with the uploaded file, check that is was indeed uploaded (see [man]is_uploaded_file[/man]).

    If it is an uploaded file, use [man]getimagesize[/man] to see if it needs resizing. If it doesn't you can just use [man]move_uploaded_file[/man] to put it where it should be (or even just [man]copy[/man], seeing as you've already checked that it was uploaded).

    If it does need resizing then use the supplied image manipulation tools to read the uploaded file, generate the resized image, and save the result to where it should be.

      Don't forget that if the image is smaller than the spec size and it is upsized the pixelaztion will make it look crapy in detail...just a thought

        Thanks I'm going to work on this tonight.

          Write a Reply...