Giter Club home page Giter Club logo

url2png-gem's Introduction

url2png gem

What is it?

A Ruby gem wrapping the url2png.com API.

Who should use it?

Any Ruby on Rails developer who wants/needs to generate screenshots from sites using url2png.com.

Usage

Installation

gem install url2png

Configuration

First define your public key and shared secret:

Url2png::Config.public_key = 'PXXXXXXXXXXXXX'
Url2png::Config.shared_secret = 'SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

If you are generating local urls in development you can use a placeholder or dummy image. This is done by setting the mode:

Url2png::Config.mode = :placehold if Rails.env.development?

Options are:

  • :production (default; will use the url2png api to generate images)
  • :placehold (will generate images at http://placehold.it)
  • :dummy (will give a grey base64 data image)

In Rails you probably want to do configuration in an initializer.

Helpers

Generate an image tag:

site_image_tag url, [options]

Options are the same as the image_tag in Rails.

By default the size is set to 400 x 400 px. To generate an image with a specific size:

site_image_tag url, :size => '300x200'

To only get the image url:

site_image_url url, :size => '300x200'

Options are:

:size
This is a proportion bounding box.
Thumbnails will be resized to fit within this box.
default: 'ORIGINAL'
examples:

site_image_tag url, :size => '500x500'

site_image_tag url, :size => 'ORIGINAL'

:thumbnail (alias for :size)

:browser_size
Set the initial browser screen size.
default: '1024x768'
min: '200x200'
max: '4000x4000'
example:

site_image_tag url, :size => '300x200', :browser_size => '1024x2500'

:delay
Extra delay (in seconds) forced between page load and screenshot.
default: 1
min: 1
max: 5
example:

site_image_tag url, :size => '300x200', :delay => 2

:fullscreen
When true, Will attempt to capture entire document canvas.
Will never return screenshot smaller than "Initial Screen Size".
default: false
example:

site_image_tag url, :size => '300x200', :fullscreen => true

Original API docs: https://url2png.com/doc/

API Version

From version 0.1.0 and up this gem is using version 4 of the url2png API.
Version 0.0.7 is the last one using version 3 of the API.

Important

This gem is written for Rails 3. Rails 2 might work but it's not tested.

Note that this gem is still under development.

Contributing to url2png

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011 Wout Fierens. See LICENSE.txt for further details.

url2png-gem's People

Contributors

gaiottino avatar jbeasley6651 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.