|
Posted by Krustov on 10/26/12 11:34
<comp.lang.php , patrick_woflian , gingercrock@hotmail.com>
<1134503075.989388.100360@g43g2000cwa.googlegroups.com>
<13 Dec 2005 11:44:36 -0800>
> but the code doesnt work and ive tried so hard to sort it out.. any one
> able to help????
>
Heres 2 files I done a while ago and they only get the images in the
directory and create the thumbnails - but they should be easy enough to
adapt to do what you want .
Keep in mind i'm a newbie and what your getting is newbie code :-)
files.php
<?php
$dirname = "images";
$dh = opendir($dirname);
while ($file = readdir($dh))
{
if (is_dir ("$dirname/$file"))
{
print "";
}
$pussy=strlen($file);
if ($pussy>4) {include('files_check.php');}
}
closedir ($dh);
?>
files_check.php
<?php
$pish=$pussy-4;
$test1=substr($file,$pish,4);
if ($test1<>".jpg") {return;}
print "$file";
$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>";
print "<br>";
?>
Navigation:
[Reply to this message]
|