Output raw image from Imagick image in PHP

前端 未结 4 991
无人及你
无人及你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 05:21

    You just need to echo your imagick object:

    $img = new Imagick($file);
    header('Content-Type: image/'.$img->getImageFormat());
    echo $img;
    

提交回复
热议问题