1
我是新来的PHP,我需要帮助。我正在尝试制作一个简单的图库。我完成了上传部分画廊的工作。现在我想从一个文件夹中获取这些图像,使它们的缩略图和将它们保存在一个数组,以便我可以稍后显示它们。 这就是我目前所挣扎的。数组在最后仍为空。使用php创建并保存一个缩略图阵列
$folder = 'images/';
$filetype = '*.*';
$files = glob($folder.$filetype);
$count = count($files);
$thumbArray = array();
for($i=0; $i<$count; $i++){
if(($img = @imagecreatefromstring($files[$i])) !== FALSE) {
$width = imagesx($img);
$height = imagesy($img);
$boxSize = min($width,$height);
$boxX = ($width/2) - ($boxSize/2);
$boxY = ($height/2) - ($boxSize/2);
$thumbArray[$i] = imagecreatetruecolor(100, 100);
imagecopyresampled($thumbArray[$i], $img, 0, 0, $boxX, $boxY, 100, 100, $boxSize, $boxSize);
}
}
在此先感谢。