开发者

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

开发者 https://www.devze.com 2023-01-09 07:10 出处:网络
I\'m trying to use Imagemagick (actually PHP\'s Imagick) to create and output (serve) an image without saving it to disk first.

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 im开发者_C百科age.

(Apache 2 server, PHP5)


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;


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消