How to display Imagick image in tag (PHP)

If you need to display an image created / opened using the Imagick library in the img tag, then you can use this code:

$image = new Imagick();
$image->readImage("test.jpg");

//output to the img tag:
echo '<img src="data:image/jpg;base64,'.base64_encode($image->getImageBlob()).'" alt="test" />';

 

Comments

No comments yet, you can leave yours: