Php 如何制作缩略图?
嘿,我有一个任务,我需要做一个画廊。这段代码我现在只显示图片,但我想为这些图片制作缩略图 我该怎么做?有什么建议吗Php 如何制作缩略图?,php,web,thumbnails,Php,Web,Thumbnails,嘿,我有一个任务,我需要做一个画廊。这段代码我现在只显示图片,但我想为这些图片制作缩略图 我该怎么做?有什么建议吗 <html> <head> <style type="text/css"> ul { list-style:none; } </style> </head> <body> <ul> <?php $imgdir = 'images/'; $allowed_type
<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>
保险商实验室{
列表样式:无;
}
尝试库。这是一个功能强大的图像处理库。这个问题/答案将帮助您,并让您了解如何重新调整图像大小
您可以使用
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;
?>
我想为这些图片制作缩略图
嗯,我想我不会反对的。你得到了我的祝福。如果您碰巧有一个确切的问题,那不是编写代码的请求,请随意在这里发布。请阅读这是已经存在的答案,我有一个明显的感觉,这应该是一个评论,而不是一个答案。