简体   繁体   English

imagick(在PHP上为Imagemagick):提供文件而不先保存到磁盘吗?

[英]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. 我正在尝试使用Imagemagick(实际上是PHP的Imagick )来创建和输出(提供)图像,而不先将其保存到磁盘。

Currently I'm having to save the file and then use verot upload class to serve the image. 目前,我必须保存文件,然后使用verot上传类来提供图像。

(Apache 2 server, PHP5) (Apache 2服务器,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: 我承认从来没有使用过Imagick,但是只看示例echoing显图像就可以了:

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

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

echo $image;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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