You are here: Re: Suggestions for creating thumbs after upload « PHP Programming Language « IT news, forums, messages
Re: Suggestions for creating thumbs after upload

Posted by Shelly on 11/20/06 12:00

"petersprc" <petersprc@gmail.com> wrote in message
news:1163997302.570180.93450@j44g2000cwa.googlegroups.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

 

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

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