Re: Making thumbnails from images
- From: "Pat" <pdavis41@xxxxxxxxx>
- Date: 29 Aug 2006 22:18:02 -0700
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
.
- References:
- Making thumbnails from images
- From: Flaming Corncob
- Making thumbnails from images
- Prev by Date: Making thumbnails from images
- Next by Date: Re: why does this not work?
- Previous by thread: Making thumbnails from images
- Index(es):
Relevant Pages
|