Hi,
I am using the following code to upload images to a folder (uploaded_files) then also create a thumbnail(uploaded_files/thumbs). I am creating the thumbnail along with the original image(on the same page parse).
When I right click on the thumb nail to view the image the width is 100px and the image is stretched in height, also the thumbnail files sometimes are larger that the original. I cannot figure out why. Any help would be appreciated, cheers
// code to upload the image.................. then....
move_uploaded_file($tmpname, $uploaddir . $photo_id);
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth)
{
$srcImg = imagecreatefromjpeg("$imageDirectory/$imageName");
$origWidth = imagesx($srcImg);
$origHeight = imagesy($srcImg);
$ratio = $origWidth / $thumbWidth;
$thumbHeight = $origHeight * $ratio;
//$thumbWidth = floor(($thumbWidth * $origHeight) / $origWidth);
$thumbImg = imagecreate($thumbWidth, $thumbHeight);
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);
imagejpeg($thumbImg, "$thumbDirectory/$imageName");
}
createThumbnail("uploaded_files", $photo_id, "uploaded_files/thumbs", 100);