You are here: Re: Help - Outputting Thumbnails « All PHP « IT news, forums, messages
Re: Help - Outputting Thumbnails

Posted by Krustov on 10/10/87 11:51

<alt.php>
<nickwired>
<27 Jun 2006 21:15:26 -0700>
<1151468126.264709.137200@d56g2000cwd.googlegroups.com>

> A novice like myself has one question :
>
> I have a few images users uploaded to a mySQL database. How can I out
> them as thumbnails.
>
> Any help would be appreciated.
>

<?php

$file="demo.jpg";

$img_name="images/$file";
$new_name="thumbs/$file";
$max_width=120;
$max_height=70;
$size=GetImageSize($img_name);
$width_ratio=($size[0] / $max_width);
$height_ratio=($size[1] / $max_height);

if($width_ratio >=$height_ratio)
{
$ratio = $width_ratio;
}
else
{
$ratio = $height_ratio;
}
$new_width=($size[0] / $ratio);
$new_height=($size[1] / $ratio);
$src_img=ImageCreateFromJPEG($img_name);
$thumb=ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($thumb,$src_img,0,0,0,0,($new_width-1),($new_height-
1),$size[0],$size[1]);
ImageJPEG($thumb,$new_name);
ImageDestroy($src_img);
ImageDestroy($thumb);

print "<img src=$new_name>";

?>

The above is some old code i had on the hard disk .

If memory serves $img_name="images/$file"; is where it gets the large
image from and $new_name="thumbs/$file"; is where it puts the thumbnail
you just created .

$max_width=120;
$max_height=70;

You can change these maximum thumbnail size defaults to suit afterwards
if wanted .


--
www.emailuser.co.uk/?name=KRUSTOV

 

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

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