calvin182 Posted November 26, 2005 Share Posted November 26, 2005 What I want to do is I want to be able to let my site users take an image from their pc, upload it into a thumbnail (max 100x100). Then I want the broswer to display the resized image so the user can save it to their harddrive. I don't want to store the image on my server (unless its temporary and for like an hour tops). I've done some searching on google and can't find what I want, anybody know of any scripts that do this? Link to comment Share on other sites More sharing options...
Goose Posted December 1, 2005 Share Posted December 1, 2005 Here is some code for resizing images. It comes from a program I wrote to automatically create galleries from a folder of images. Definately works for jpg. But I saved the thumbnails to my servers harddrive - you could ignore that part and use the imagedestroy function after you've displayed it. Hope this helps.if ($type == "jpg" || $type == "jpeg" || $type == "JPG" || $type == "JPEG"){ $img_source = imagecreatefromjpeg($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = ($newWidth/$oldWidth)*$oldHeight; $img_destination = imagecreatetruecolor($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagejpeg($img_destination,$this->options->thumb_path . "thumb" . $imagename,100); return $this->options->thumb_path . "thumb" . $imagename;}elseif ($type == "gif" || $type == "GIF"){ $img_source = imagecreatefromgif($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = intval((doubleval($newWidth)/doubleval($oldWidth))*$oldHeight); $img_destination = imagecreate($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagegif($img_destination,$this->options->thumb_path . "thumb" . $imagename); return $this->options->thumb_path . "thumb" . $imagename;}elseif ($type == "png" || $type == "PNG"){ $img_source = imagecreatefrompng($this->path.$imagename); $oldWidth = imagesx($img_source); $oldHeight = imagesy($img_source); $newHeight = intval((doubleval($newWidth)/doubleval($oldWidth))*$oldHeight); $img_destination = imagecreate($newWidth,$newHeight); imagecopyresized($img_destination,$img_source,0,0,0,0,$newWidth,$newHeight,$oldWidth,$oldHeight); imagepng($img_destination,$this->options->thumb_path . "thumb" . $imagename); return $this->options->thumb_path . "thumb" . $imagename;} Link to comment Share on other sites More sharing options...
calvin182 Posted December 2, 2005 Author Share Posted December 2, 2005 so how do I use this... I am very new to php here. I guess what I need to figure out is how to upload the image to the code and set it so the output is 100x100 or less (correct proportions). Any advice? Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 3, 2005 Share Posted December 3, 2005 You may need to learn some PHP basics first, go see the tutorial at the site Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now