Search code examples
phpscreenshot

In PHP, is it possible to take web page screenshots in memory?


By "in memory", I mean that the screenshot won't be written to a file.

The requirement is to generate thumbnails of a web page that will be stored in the database. I know that saving images in the database is not recommended, but we might not have write permissions in our server, so we are exploring this option.

If it's possible, how is it done?


Solution

  • This would require a webpage renderer written in PHP, and as far as I know, there is no library that does this. There are however several command-line tools that can do this (CutyCapt is one example), but they will write to a file.

    As regards write permissions, you might be able to write to /tmp and then do a pass-through via PHP.