【发布时间】:2011-02-25 18:53:55
【问题描述】:
对于那些可能已经阅读了我在几分钟前得到解决的上一个问题的人>。
on-the-fly php 脚本完美运行,但是当我将新图像上传到我自己制作的画廊时,图像被调整为 150 x 150 以达到我想要的大小......但是,当它出现时添加的新图像全是黑色的......
如您所见,上传到文件夹的三个黑色图像和添加到数据库的目录。
其他(非黑色图像)已使用 image.php 调整大小。
这是什么原因造成的?
如果我查看源代码,代码很好...... PHP 中的 while 循环会生成如下输出:
<div class="view-wrap" id="photo-10">
<div class="view-icon">
<div class="img-label">
<a href="#" id="10" class="delete"><img src="img/small-delete.png" /> Delete</a>
</div>
<a href="img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg">
<img src="image.php?dir=img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg" alt="" width="110" height="110" />
</a>
</div>
</div>
一个块的例子。
如果我查看源代码(在 Firefox 中)并单击 image.php?dir=img/events/Paintballing/24251_1395408043148_1170626626_1204038_5382765_n.jpg 示例,我可以看到 150 x 150 大小的缩略图,但在布局中,它显示一个黑色缩略图...
有人知道为什么会这样吗?
编辑:
<?php
$dir = $_GET['dir'];
header('Content-type: image/jpeg');
$create = imagecreatetruecolor(150, 150);
$img = imagecreatefromjpeg($dir);
list($width, $height) = getimagesize($dir);
imagecopyresampled($create, $img, 0, 0, 0, 0, 150, 150, $width, $height);
imagejpeg($create, null, 100);
?>
这是 image.php。
【问题讨论】:
标签: php image-processing thumbnails