Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (44 sloc) 2.64 KB


Provides rails helpers for interfacing with PeepShot.


PeepShot can be integrated into your Rails application in two ways:

Use the PeepShot image tag helper: peepshot_image_tag(url, options)

The minimum requirements for the peepshot_image_tag is an url and a width. When no height is given, PeepShot will return an un-cropped screenshot of the full page. The following example will return an 320px wide image with a height above 1000px.

<%= peepshot_image_tag("", :width => 450) %>

Will return something like this:

<img alt="Ui-patterns" src="" width="450" />

The maximum width of a screenshot is 1024 pixels.

Adding a height to the options hash will make PeepShot crop the screenshot with basis in the top left corner.

<%= peepshot_image_tag("", :width => 450, :height => 337) %>

Will return something like this:

<img alt="Ui-patterns" height="337" src="" width="450" />

You can add any HTML options you'd like as you would with a regular image_tag in rails:

<%= peepshot_image_tag("", :width => 450, :height => 337, :class => 'thumbnail', :alt => "Go to") %>

Use the PeepShot url helper: peepshot_url(url, options)

If you'd like to use peepshot in your own homebrewn way, you can skip the image tag, and just get the URL for the thumbnail:

peepshot_url("", :width => 320)


Prerequisite: You need a account. Have your API Key and API Secret handy.

1. Install peepshot as a gem in your rails app.

Add this to your Gemfile: (change version numbers if needed)

gem 'peepshot', '0.2.0'

Don’t forget to run “bundle install” command every time you change something in the Gemfile.

2. Create config/peepshot.yml with the appropriate environment.

  api_key: <your API key>
  api_secret: <your API secret>

3. Create config/initializers/peepshot.rb and place the following line in it



Unit tests use rspec and require the following environment configuration to run: rails 2.3.10 rspec 1.3.1 rspec-rails 1.3.3 json 1.4.0

Invoke tests on Mac/Linux by running rake spec from this directory

Invoke tests on Windows by running spec spec/ from this directory

Copyright (c) 2012 Anders Toxboe, released under the MIT license

Jump to Line
Something went wrong with that request. Please try again.