0

ねえ、ギャラリーを作る必要がある課題があります。このコードは写真を表示するだけですが、これらの写真のサムネイルを作成したいと考えています。

これどうやってするの?助言がありますか?

<html>
<head>
<style type="text/css"> 

ul {
    list-style:none;
}

</style>

</head>
<body>
<ul>
<?php
    $imgdir = 'images/';
    $allowed_types = array('png', 'jpg', 'jpeg', 'gif');
    $dimg = opendir($imgdir);
    while($imgfile = readdir($dimg)) {
        if(in_array(strtolower(substr($imgfile, -3)), $allowed_types) or in_array(strtolower(substr($imgfile, -4)), $allowed_types)) {
            $a_img[] = $imgfile; 
        }
    }
    echo "<ul>";

    $totimg = count($a_img);
    for($x=0; $x < $totimg; $x++) {
        echo "<li><img src='" . $imgdir . $a_img[$x] . "' /></li>";
    }
    echo "</ul>";

?>
</ul>
</body>
</html>
4

3 に答える 3

0

Imagick拡張機能を使用できます。

このようなもの:

<?php

header('Content-type: image/jpeg');

$image = new Imagick('tc5.jpg');

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

?> 

http://php.net/manual/en/imagick.cropthumbnailimage.php

于 2013-03-18T09:53:39.127 に答える
0

この質問/回答はあなたを助け、画像のサイズを変更する方法を教えてくれます。

PHP での画像のサイズ変更

于 2013-03-18T09:45:24.667 に答える
0

Imagineライブラリを試してみてください。強力な画像処理ライブラリです。

于 2013-03-18T09:40:19.943 に答える