A
Anonymous
Guest
This script I made is supposed to take an image via http://site.com/ImageThumbnail.php?/ImageFileName=sue.jpg and return the same image reduced to 144 x Calculated Width.
Here is the code, something doesn't work. I'll include my notes and everything...
Here is the code, something doesn't work. I'll include my notes and everything...
Code:
<? // This File will take "$file" and resize it from whatever size it is to 152 width X 114 height
//open image
//make destination image via imagecreatetruecolor()
//Make Proportion. If I want the height to be 114, then I'll make a proportion like this
// ho/wo = 114/x
//Find size of original
//resize image avec imagecopyresampled(
// a / b = c / d
// ad = bc
// d = bc/a
// 5/8 = 10/x
header("Content-type: image/jpeg");
$ThumbnailOriginal = $imagecreatefromjpeg("$ImageFileName"); // Opens up the image.
$NewHeight = 144; // Thumbnail Destination Height.
$OriginalSize = getimagesize("$ThumbnailOriginal"); // Get Dimesions of Image.
$NewWidth = ($OriginalSize[0]*$NewHeight)/$OriginalSize[1]; // GetDimesions of Destination Image.
$ThumbnailDestination = $imagecreatetruecolor($NewWidth, $NewHeight);
imagecopyresampled($ThumbnailDestination, $ThumbnailOriginal, $NewWidth, $NewHeight, $OriginalSize[0], $OriginalSize[1], $NewWidth, $NewHeight, $OriginalSize[0], $OriginalSize[1]);
ImageJpeg($ThumbnailDestination);
?>