Search code examples
phpimagick

Imagick not displaying to page with content headers set


I am having some trouble getting getImagesBlob(); to display to page when headers are set.

the code below returns a courrpt image symbol in the browser

header('Content-type: image/jpeg');
$combined->setImageFormat('jpg');
echo $combined->getImagesBlob();

However, if I don't set the content type and display the image within an image tag this works

echo "<img src='data:image/jpg;base64,".base64_encode($combined->getImagesBlob())."' />";

Solution

  • Had an echo in the code which was causing this error. Deleting the extra echo was the fix.