1

I'm trying to create a thumbnail of an image, however, I can display it just fine, but cannot save it.

For example:

$image = new Imagick("photo.png");
$image->thumbnailImage(100, 0);
header("Content-Type: image/png");
echo $image;

This will in fact display my image in its thumbnailed form. But if I instead try to save it using $image->writeImage("thumb_photo.png") the script appears to stop (I confirmed this just by putting echo Hello or whatever afterwards) and no files have been created.

I'm using this on a server with Debian Wheezy, nginx, and PHP setup. The directory and PHP files themselves are readable, writable and have execute permissions for both the images and PHP files themselves. The imagick module version is 3.10. The PHP version is 5.4.

If someone can tell me what the problem could be I would appreciate it.

EDIT: After getting the exception, I am presented with WriteBlob Failed "thumb_photo.png" @ error/png.c/MagickPNGErrorHandler/1728.

另一件事,显然如果我将输出从“thumb_photo.png”更改为“photo.png”,它可以工作,但会覆盖我的图像,我怎么能解决这个问题以及两个为什么它会让我覆盖我的图像而不是创建一个新的一?

4

2 回答 2

2

显然我忘记将组更改为www-data文件路径的文档根目录。我还需要添加chmod -R g+s它。去搞清楚。

于 2013-03-31T02:09:16.813 回答
0

我发现如果 www-data 不存在,您可以将所有权更改为 apache:apache 并让我保存到该文件夹​​。我正在使用带有标准 php/mysql 的 Centos 7。

于 2016-04-09T12:00:12.487 回答