Output raw image from Imagick image in PHP
问题 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 to use Imagick::writeImage('STDOUT') (empty output) and 'php://stdout' with error "Unable to write to file". Any ideas? :) 回答1: You just need to echo your imagick object: $img = new Imagick($file); header('Content-Type: image/'.$img->getImageFormat()); echo $img; 回答2: I believe what Schneck meant is: header('Content-Type: '.$mime