嘿,我有一個任務,我需要做一個畫廊。這段代碼現在只顯示圖片,但我想爲這些圖片製作縮略圖。如何製作縮略圖?
我該怎麼做?有什麼建議麼?
<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>
使用GD庫 – Stasel 2013-03-18 09:37:58
'我想使縮略圖這些pictures'嗯,我想我也不會反對。你已經得到了我的祝福。如果你碰巧有一個確切的_question_,那不是寫你的代碼的請求,隨意在這裏發佈它。並請閱讀[常見問題] – ppeterka 2013-03-18 09:41:05
http://stackoverflow.com/questions/5254325/using-the-php-gd-library-to-resize-and-save-images-is-hell這是已有的答案所以。 – 2013-03-18 09:42:34