Recently I've been playing around with GD and uploading images, up until now I've been showing the original images but with set widths and heights while I searched for a function which will resize and show my images in a preview like http://www.sxc.hu/
I found my way to the PHP.net manual and browsed about the function list until I came across the following code;
// The file
$filename = 'test.jpg';
// Set a maximum height and width
$width = 200;
$height = 200;
// Content type
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
If you are going to be using thumbnails for pictures, I would suggest having a thumbnail image and the original image. Keep them in different folders with the same name or something like that.
What I usually do is, when a user uploads a picture I create 3 pictures from it. A small, medium, and large. I use GD to constrain the proportions of the 3 and put them in separate folders. Then if I want to use a thumbnail, I pull the image from the small folder. If they want to view a larger images, I pull it form the large folder.
I would prefer to just create previews of the original images though.
What I'm trying to do, along the lines of an image gallery, a user uploads an image with data to the database, the database stores the image name and the rest of the data.
When my information gets displayed I just echo out the variable containing the image names ... but these are the full size images, I would like to have previews generated of those original images to help keep the image file size down and keep the correct image proportions.
Originally posted by joe2kiss I would prefer to just create previews of the original images though.
That's pretty much what I said to do. When a user uploads, use gd to create to resize a preview image to whatever size you want. I actually use the exec method with PHP and call convert on the local file system to do it.