php cropping/saving uploaded image

  • Thread starter Thread starter Sic
  • Start date Start date

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
hello, my good OcUKers. i've just written a lovely little script for uploading files (even if i do say so myself!)

i'm concentrating on the image facet at the moment, and i'd like to be able to copy my uploaded image to a different older, crop it, then save it for future use. could anyone give me an insight into which functions i should use? i just saw imagecopy() but that only appears to use a temporary image file to project a copied crop onto. can anyone point me in the right direction here please? (it's imperative that i'm able to save the copied image. i'm sure that is very relevant. (my php image control isn't particularly great, so i may have missed something totally fundamental!)

thank you guys :)
 
Once you've manipulated the image, just use imagepng/imagejpeg/imagegif and pass a second argument with the filename of the new image.

To clarify, this:

Code:
imagepng($im);

Will output $im in PNG format to the browser, whereas:

Code:
imagepng($im, 'foo.png');

Will output $im in PNG format to a file called 'foo.png'.
 
Back
Top Bottom