How to use imagick's writeImage() function?

社会主义新天地 提交于 2019-12-06 23:29:24

问题


This works if I keep the script in the same directory as the image being manipulated. And the resultant image "foo.jpg" is also generated in the same location.

<?php

$im = new imagick('image.jpg');
$im->thumbnailImage( 200, 0);
$im->writeImage("foo.jpg");

?>

But what if the script is in one location and the image I wish to work with is in another and the location I wish to save the thumbnail to is somewhere else, how to specify these paths?

Doing something like this doesn't work:

$im = new imagick('path/to/image.jpg');

回答1:


Might be some file system problem. Try and get a file pointer in php first and check for any problems

$fileHandle = fopen("path/to/image.jpg", "w");

You can then use Imagick function (version 6.3.6 or newer);

$im->writeImageFile($filehandle);


来源:https://stackoverflow.com/questions/8623525/how-to-use-imagicks-writeimage-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!