ruby-thumbor <img src=“https://secure.travis-ci.org/thumbor/ruby-thumbor.png?branch=master” alt=“Build Status” /> <img src=“https://gemnasium.com/thumbor/ruby-thumbor.png” alt=“Dependency Status” /> <img src=“https://badge.fury.io/rb/ruby-thumbor.svg” alt=“Gem Version” />

DESCRIPTION:

ruby-thumbor is the client to the thumbor imaging service (github.com/thumbor/thumbor).

FEATURES:

  • Generate thumbor encrypted URLs

  • Obtain metadata from image operations in thumbor

DEPENDENCIES

No dependencies required for regular usage.

INSTALL:

gem install ruby-thumbor

gem 'ruby-thumbor'

BREAKING CHANGE ON 2.0:

Thumbor::Cascade.new now gets key, image

USAGE:

require 'ruby-thumbor'

crypto = Thumbor::CryptoURL.new 'my-security-key'

url = crypto.generate :width => 200, :height => 300, :image => 'my.server.com/path/to/image.jpg'

# url will contain something like:
# /2913921in321n3k2nj32hjhj3h22/my.server.com/path/to/image.jpg

or

require 'ruby-thumbor'

image = Thumbor::Cascade.new('my-security-key', 'my.server.com/path/to/image.jpg')
image.width(300).height(200).watermark_filter('http://my-server.com/image.png', 30).generate

Available arguments to the generate method:

:meta => bool - flag that indicates that thumbor should return only meta-data on the operations it would
                otherwise perform;

:crop => [<int>, <int>, <int>, <int>] - Coordinates for manual cropping. The first item is the two arguments are
                                        the coordinates for the left, top point and the last two are the coordinates
                                        for the right, bottom point (thus forming the square to crop);

:width => <int> - the width for the thumbnail;

:height => <int> - the height for the thumbnail;

:flip => <bool> - flag that indicates that thumbor should flip horizontally (on the vertical axis) the image;

:flop => <bool> - flag that indicates that thumbor should flip vertically (on the horizontal axis) the image;

:halign => :left, :center or :right - horizontal alignment that thumbor should use for cropping;

:valign => :top, :middle or :bottom - horizontal alignment that thumbor should use for cropping;

:smart => <bool> - flag that indicates that thumbor should use smart cropping;

If you need more info on what each option does, check thumbor’s documentation at github.com/thumbor/thumbor/wiki.

CONTRIBUTIONS:

  • Hugo Lopes (hugobr) - Fixes in the usage readme part of the docs.

LICENSE:

(The MIT License)

Copyright © 2011 Bernardo Heynemann <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.