Output raw image from Imagick image in PHP

前端 未结 4 992
无人及你
无人及你 2020-12-09 04:23

I\'m using Imagick lib to do some modifications to original image. Then I\'d like to output it directly to browser without saving. Is there a way to do that?

I tried

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 05:19

    If you're using HHVM it'll throw a fatal exception if you just try and echo the Imagick object so you'll need to call getimageblob();

    $imagick = new Imagick('my-image.jpg');
    header('Content-Type: image/' . $imagick->getImageFormat());
    echo $imagick->getimageblob();
    

提交回复
热议问题