我希望将目录中删除的所有图像作为缩略图复制到单独的目录中,然后我可以在我的网站上查看。现在我正在研究phpthumb,但也下载了wideimage和zen照片。
如果你能找到一个完全相同的副本,谢谢你,附近的比赛也可能会有所帮助。
以下是仅复制单个文件的脚本:
require_once '../ThumbLib.inc.php';
//include the thumb library
$thumb = PhpThumbFactory::create('test.jpg');
//create a new image from the targeted jpegs
$thumb->adaptiveResize(100, 100);
//resize
$thumb->save('test.png', 'png');
//save as 'test' with the file type png
//echo "<img src='$thumb' class='thumb'>";
$thumb->show();
//print the thumbnail to the screen
答案 0 :(得分:2)
尝试
$dir = "photos" ;
$destination = "thumb" ;
$images = scandir($dir);
foreach ( $images as $image ) {
if(is_file($image))
{
$ext = pathinfo ( $dir . DIRECTORY_SEPARATOR . $image, PATHINFO_EXTENSION );
$thumb = PhpThumbFactory::create ( $dir . DIRECTORY_SEPARATOR . $image );
$thumb->adaptiveResize ( 100, 100 );
$thumb->save ( $destination . DIRECTORY_SEPARATOR . $image, $ext );
$thumb->show ();
}
}