"petersprc" <pe*******@gmail.comwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
phpThumb can do this:
http://phpthumb.sourceforge.net/
It can cache requests, so you could have the thumbnails be generated
automatically.
An article on creating thumbnails with gd:
http://icant.co.uk/articles/phpthumbnails/
Duane Phillips wrote:
>On image upload, I would like to save the image and also auto-create a
right-size image for faster browsing, and also a thumbnail for indexes,
so
that slower connections do not have to wait for the larger image, and I
can
store preferences for each user as to what sizes they prefer to wait for.
Are there PHP code/tools to do this? Would sure appreciate a pointer in
the
right direction.
TIA.
~ Duane Phillips.
Here is a little function I put together after getting tips from this group:
function thumbnail($img, $w_d, $h_d) {
// $img is the image
// $w_d is the desired width in pixels
// $h_d is the desired height in pixels
//
// function to get the width and height to display q thumbnail
// Pass in the image location, the deisred width and the desired height
// Ouput is an array of height and width to display that can be
// exploded with the list command
list($w, $h, $type, $attr) = getimagesize($img);
$calc_width = $h_d * $w / $h;
$calc_height = $w_d * $h / $w;
if ($calc_width <= $w_d) {
$disp_width = $calc_width;
$disp_height = $h_d;
} else {
$disp_width = $w_d;
$disp_height = $calc_height;
}
return array($disp_width, $disp_height);
}
// Testing with a picture of coda, width of
list($disp_width, $disp_height) =
thumbnail("the_picture_location_and_name", the_max_height, the_max_width);
// The picture dimensions, $disp_width and $disp_height, are put in
with php brackets in the html declaration