简体   繁体   中英

Imagick (Imagemagick on PHP): serve a file without saving 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 image.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM