Coder Social home page Coder Social logo

filepreviews-ruby's Introduction

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

filepreviews-ruby's People

Contributors

jonahoffline avatar rrrene avatar jamesbrooks avatar jpadilla avatar

Watchers

 avatar James Cloos 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.