{"id":60,"date":"2010-07-29T12:06:12","date_gmt":"2010-07-29T17:06:12","guid":{"rendered":"http:\/\/blog.mozilla.org\/ted\/?p=60"},"modified":"2012-05-11T08:06:36","modified_gmt":"2012-05-11T13:06:36","slug":"moz-headless-screenshot","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/ted\/2010\/07\/29\/moz-headless-screenshot\/","title":{"rendered":"moz-headless-screenshot"},"content":{"rendered":"<p>On a <a title=\"qumbler: stuff, etc.\" href=\"http:\/\/qumbler.com\/\">personal project of mine<\/a>, I have a need to generate thumbnails of web pages. Until recently my solution was to use <a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/firefox.html\">Firefox<\/a> running in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Xvfb\">Xvfb<\/a>, a virtual X server. This is not an ideal solution, as it requires you to have lots of X client libraries installed on your server. Additionally, Firefox is not intended for this purpose, so there are lots of ways for things to go wrong.<\/p>\n<p>Because of this, I&#8217;d been following <a href=\"http:\/\/chrislord.net\/\">Chris Lord<\/a>&#8216;s work on the <a href=\"http:\/\/hg.mozilla.org\/incubator\/offscreen\/\">offscreen branch<\/a> of Mozilla for some time, but never tried it out until recently. The offscreen branch provides a widget backend for Mozilla that can render web content to an offscreen buffer. Chris wrote it in support of <a href=\"http:\/\/www.clutter-project.org\/\">Clutter<\/a>, which is a pretty neat use case. Conveniently, he also provided a sample embedding client application called moz-headless-screenshot. This is a simple command line tool that takes a URL, image size, and output filename and generates a PNG screenshot of the webpage. This being exactly what I wanted, and having my poorly-written Firefox+Xvfb solution fall apart due to a server migration, I decided to give his solution a shot.<\/p>\n<p>I hit a few speed bumps on the way, since there wasn&#8217;t much documentation to be found on actually building and using moz-headless-screenshot. I&#8217;ve attempted to fix this my providing <a href=\"http:\/\/ted.mielczarek.org\/hg\/moz-headless-screenshot\/file\/tip\/Makefile\">detailed steps and a Makefile<\/a> in <a href=\"http:\/\/hg.mozilla.org\/users\/tmielczarek_mozilla.com\/moz-headless-screenshot\/\">my own moz-headless-screenshot repository<\/a>. I&#8217;ve also modified the code slightly such that it&#8217;s easier to run (at least in my use case). I have heard from others over the years that have this same need, so hopefully someone else finds it useful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On a personal project of mine, I have a need to generate thumbnails of web pages. Until recently my solution was to use Firefox running in Xvfb, a virtual X server. This is not an ideal solution, as it requires you to have lots of X client libraries installed on your server. Additionally, Firefox is [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/ted\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}