Search code examples
phpimagescreen-grab

Display image in PHP given image content


I'm using the GrabzIt PHP library and it returns screenshots of webpages.

The library returns the image content to be saved as a file, e.g:

file_put_contents('images/screenshot.png', $grabzitImageContents);

I want to display this image in the page without saving the image (uses server space). Is it possible?


Solution

  • You could just send the header and then echo the data:

    header("Content-Type: image/png");
    echo $grabzitImageContents;
    

    Try it.