<?php
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
$dir = opendir( $pathToImages );
while (false !== ($fname = readdir( $dir ))) {
$info = pathinfo($pathToImages . $fname);
if ( strtolower($info['extension']) == 'jpg' )
{
echo "Creating thumbnail for {$fname} <br />";
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
closedir( $dir );
}
createThumbs("upload/","upload/thumbs/",100);
?>
<?php
function createGallery( $pathToImages, $pathToThumbs )
{
echo "Creating gallery.html <br />";
$output = "<html>";
$output .= "<head><title>Thumbnails</title></head>";
$output .= "<body>";
$output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">";
$output .= "<tr>";
$dir = opendir( $pathToThumbs );
$counter = 0;
while (false !== ($fname = readdir($dir)))
{
if ($fname != '.' && $fname != '..')
{
$output .= "<td valign=\"middle\" align=\"center\"><a href=\"{$pathToImages}{$fname}\">";
$output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
$output .= "</a></td>";
$counter += 1;
if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; }
}
}
closedir( $dir );
$output .= "</tr>";
$output .= "</table>";
$output .= "</body>";
$output .= "</html>";
$fhandle = fopen( "gallery.html", "w" );
fwrite( $fhandle, $output );
fclose( $fhandle );
}
createGallery("upload/","upload/thumbs/");
?>
分享到:
相关推荐
winform开发小图片
1000张网页GIF小图片类似一些登陆搜索new注册上一页下一页的小图片做网页的时候用的到的小素材
500个网页常用小图片 500个网页常用小图片
你还在为做项目的小图片而查找么?该文件包含素材全面广泛。对做项目很有用哦
1000张网页小图片,网页制作必备,请下载请珍惜,你一定用得上
android界面小图片大全,有你想要的。都能用得着。完美
里面包含常用的1000张网页GIF小图片
小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片放大几十倍仍然清晰小图片...
各种网页绘画时候的实用小图片。png 格式的 jif 格式的等
一张简单的风景小图片,喜欢的来大家来下下,给点意见,谢谢
做网站经常用到的75个网页小图片做网站经常用到的75个网页小图片做网站经常用到的75个网页小图片
动态流程展示中可能用到的小图片。。。。 动态流程展示中可能用到的小图片。。。。
本人免费从其他地方下的,就免费分享给大家吧 一些常用的PNG网路小图片,喜欢的可以下来看看
制作网页所需的动感的gif小图片,呵呵,里面有许多漂亮的小图片呢,呵呵,希望对你们有帮助啊!
PHP常用图片,很有用!包括一笑小的图片……等等
把你电脑上的小图片放大后会模糊,边缘有锯齿,有了这个小软件会让你消除这些顾虑。图片放大后不失真。内附注册信息。
实现效果: 网页上有一个小图片,在点击时,会弹出大图片,弹出时会有特殊效果,非常漂亮 采用Vs2005 开发
精美小图片精美小图片精美小图片精美小图片精美小图片
网站开发小图片集合