You are here: Re: Making thumbnails from images « All PHP « IT news, forums, messages
Re: Making thumbnails from images

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация