Imagick (Imagemagick on PHP): serve a file without saving to disk first?

空扰寡人 提交于 2020-01-02 09:20:08

问题


I'm trying to use Imagemagick (actually PHP's Imagick) to create and output (serve) an image without saving it to disk first.

Currently I'm having to save the file and then use verot upload class to serve the image.

(Apache 2 server, PHP5)


回答1:


Sure. This should work for you:

$image = new Imagick();
// Do your image creation stuff. Make sure to set $image->setImageFormat();

header('Content-Type: image/filetype'); // Change filetype
echo $image;



回答2:


I admit to never having used Imagick, but just looking at the examples, echoing the image should work just fine:

header('Content-type: image/jpeg');

$image = new Imagick('image.jpg');

echo $image;


来源:https://stackoverflow.com/questions/3369739/imagick-imagemagick-on-php-serve-a-file-without-saving-to-disk-first

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