__| __| _ \ __| __| \ | __| | | _ \ _ \ __ __| __| _ \ \__ \ ( / _| _| . | \__ \ __ | ( | ( | | _| / ____/ \___| _|_\ ___| ___| _|\_| ____/ _| _| \___/ \___/ _| ___| _|_\
A little web service that takes the URL of a web page and returns a URL to an image of that page.
We use this to create PNGs of SVGs served by our Rails apps and to make up-to-date images of Raphael graphics for sharing on Facebook and Twitter.
screenshooter.sample.yml and add your S3 credentials.
Start the server:
ruby -rubygems screenshooter.rb
From any machine, shoot a URL:
curl "http://localhost:4567/?url=http://tycho.usno.navy.mil/cgi-bin/timer.pl" curl "http://localhost:4567/?url=http://raphaeljs.com/tiger.html"
And the images show up at:
url: The url you would like to generate an image from.
clip: Area of the page to display. Consists of 4 integers (left, top, width, height) to be passed to clipRect.
resizeheight: Resize the generated image to the specified size (via ImageMagick) before uploading. If only a width is supplied, the height is scaled proportionally.
hb: Hashbang to add to the url.
callback: Wrap the response in the specified function name for use with jsonp.
timestamp: If set to
true, a version of the file with a timestamp added to the filename will also be uploaded to s3 (in addition to a version without the timestamp). Useful for maintaining historic images of an url or generating unique image files. The base image (without the timestamp appended) will always be the most recent screenshot.
cachetime: Adds a Cache-Control header to the uploaded s3 file.
Cache-Control: public, max-age=600to the uploaded s3 file
By default, screenshooter can create images of urls on any domain. If you would like to whitelist specific domains (useful for making sure nobody misuses your instance of screenshooter), add them to screenshooter.yml. Entries are made in Ruby regex format.
- Jay Boice, email@example.com
- Aaron Bycoffe, firstname.lastname@example.org
- Andrei Scheinkman, email@example.com
Copyright (c) 2012 The Huffington Post. See LICENSE for details.