0

ディレクトリにドロップされたすべての画像を別のディレクトリにサムネイルとしてコピーして、自分のサイトで表示できるようにしたいと考えています。現在、私はphpthumbを研究していますが、ワイドイメージと禅の写真もダウンロードしています。

これと完全に一致するものを見つけることができれば、ありがとうございます。ほぼ一致するものも役立つ場合があります。

単一のファイルのみをコピーするスクリプトは次のとおりです。

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
4

1 に答える 1

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 ();
    }
}
于 2012-04-26T19:24:14.483 に答える