PDA

View Full Version : Php - resize and save a copy of an image on upload?




PyroVesten
Nov 6, 2004, 06:36 AM
Is anyone able to shed some light on how I'd go about getting php to resize images I upload through a form and saving a copy at 1/2 the size?

I run pyromusic.net and at the moment everything is updated manually. It's a pain in the arse to say the least..

I'm working on getting a review submission form online which will have a bunch of fields (Artist, Title, Score, Website, Label etc) which, when submitted, will be sent to a review database, additionally it will have a text box for the tracklist which will go into another table, a text box for the review text which will be sent to a .txt file and convert new lines into <p> tags, and lastly a file upload box where a I upload the cover image.

I want the image upload form to save the unaltered copy of the cover image to one directory and have a resized copy (which would always be 75 by ?? pixels - CD covers are 150x150, DVD covers are obviously higher but still 150 wide) of the image saved to another directory with the same file name.

How difficult would it be to write code for this or would anyone be able to be of some assistance?

Cheers in advance.



angelneo
Nov 6, 2004, 07:59 AM
You will need to use the GD library which can be found here:

http://www.boutell.com/gd/

a set of functions in php is available for use. you can find the api here

http://www.php.net/manual/en/ref.image.php