Re: Generating thumbnails of JPEG/GIF images
| From: | Web master | Date: | Fri, 04 May 2001 16:29:39 +0000 |
| Subject: | Re: Generating thumbnails of JPEG/GIF images | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-51438@lists.php.net to get a copy of this message | ||
I wrote a small function like the following to create my won thumbnails.
function make_tumb_nail($url){
$size=GetImageSize("image/$url");
$ht=$size[1];
$wd=$size[0];
if($ht>$wd){
$h=$ht;
for($i=1.01;;){
if($h<121){
break;
}
$h=$ht/$i;
$w=$wd/$i;
$i=$i+0.01;
}
} else {
$w=$wd;
for($i=1.01;;){
if($w<91){
break;
}
$h=$ht/$i;
$w=$wd/$i;
$i=$i+0.01;
}
}
$wd=floor(round($w));
$ht=floor(round($h));
$returnstring="width=$wd height=$ht border=0";
return $returnstring;
}
This function returns the thumbnail width and height as string and use it along with the original string.
<img src="image/<?php $url ?>" <? php make_thumb_nail($url) ?>>
Hope this helps.
Richard wrote:
Greetings.Is there any quick way to generate thumbnails of existing pictures in adirectory? It would seem quite worthless to create 120x120 images of ones that already exist, and upload duplicates.. Therefore, dynamic thumbnails would be perfect. Any solutions?PHP 4.0+ thanks.- Richard