Skip to content

Ruby gem and Command-Line App for Filepreviews.io

License

Notifications You must be signed in to change notification settings

filepreviews/filepreviews-ruby

 
 

Repository files navigation

FilePreviews.io (Ruby client)

Gem Version Build Status Dependency Status Code Climate Gitter chat Inline docs

Ruby client library and CLI tool for the FilePreviews.io service. Generate image previews and metadata from almost any kind of file.

Installation

Add this line to your application's Gemfile:

gem 'filepreviews'

And then execute:

$ bundle

Or install it yourself as:

$ gem install filepreviews

Usage

Register your application for an API key at FilePreviews.io.

Configuration

To configure the gem to use your newly-registered api + secret keys, you can use one of the two configuration styles:

Block style:

require 'filepreviews'

Filepreviews.configure do |config|
  config.api_key = 'YOUR_API_KEY'
  config.secret_key = 'YOUR_SECRET_KEY'
end

Simpler style:

require 'filepreviews'

Filepreviews.api_key = 'YOUR_API_KEY'
Filepreviews.config.secret_key = 'YOUR_SECRET_KEY'

Basic Example Code

require 'filepreviews'

url = 'http://pixelhipsters.com/images/pixelhipster_cat.png'
result = Filepreviews.generate(url)

result.url
result.status
result.metadata # fetches metadata

Web Page Screencaptures

url = 'http://pixelhipsters.com'
result = Filepreviews.generate(url)

result.url
result.status
result.metadata

Options

You can optionally send an options object (per request).

conf = {
  options: {
    size: {
      width: 100,
      height: 999
    },
    # supported: 'exif', 'ocr', 'psd', 'checksum', 'multimedia',
    metadata: ['exif'],

    # supported: 'jpg', 'jpeg', 'png'
    format: 'jpg',

    # supported: '1', '1-3', '1,3,5', '1-3', 'all'
    pages: '1-3'
  }
}

result = Filepreviews.generate(url, conf)
result.url
result.metadata

Command-Line Application

Options:

  • -k, --api_key [key] - use API key from Filepreviews.io
  • -s, --secret_key [key] - use secret key from Filepreviews.io
  • -m, --metadata - load metadata response
  • -v, --version - display the version
  • -h, --help - print help

Command-Line usage examples

Basic use

$ filepreviews http://www.pixelhipsters.com

With an API Key

$ filepreviews --api_key YOUR_API_KEY_HERE --secret_key YOUR_SECRET_KEY_HERE http://www.pixelhipsters.com

Autoload Full (metadata) Response

$ filepreviews -m http://pixelhipsters.com/images/pixelhipster_cat.png

Note: This will return a full metadata response, instead of the API's original response that only returns the url and status of the request.

Author

Discussion

If you have any questions, ideas or jokes:

Gitter chat

Contributing

Is it worth it? let me fork it

I put my thing down, flip it and debug it

Ti gubed dna ti pilf nwod gniht ym tup I

Ti gubed dna ti pilf nwod gniht ym tup I

About

Ruby gem and Command-Line App for Filepreviews.io

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%