Reply to Re: showing images from a directory

Your name:

Reply:


Posted by Krustov on 10/07/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>";

?>

[Back to original 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

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