|
Posted by Pat on 08/30/06 05:18
Here is part of the resize script that I wrote...
// Check to make sure new width is not larger than the original width
if ($new_width > $width) {
$new_width = $width;
}
// Calculate the new height of the image based upon the passed width
$ratio = $width/$height;
$new_height = round($new_width/$ratio);
// Create a image to manipulate from the data from the database
$image = imagecreatefromstring($blob);
// Resize the Image
$image_p = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);
// Output image to browser
header( "Content-type: ".$type);
imagejpeg($image_p);
Since I am pulling the image from a database with this script you might
have to make some changes (like the type in the header statement).
This script outputs the image to the browser, but you could easily have
it output to a file by changing the imagejpeg statement and removing
the header statement.
I hope this helps you out!
Pat Davis
Navigation:
[Reply to this message]
|