0.0
No commit activity in last 3 years
No release in over 3 years
A simple way to create thumbnails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 5.0
~> 10.0
 Project Readme

Thumbnailer

A simple way to create thumbnails.

Installation

Add this line to your application's Gemfile:

gem 'thumbnailer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install thumbnailer

Usage

Creating from a file

thumb = Thumbnailer::File.new('ruby-logo.png')
thumb.create # creates thumb_ruby-logo.png with 1/10 of the original size

Creating from a file mask

thumb = Thumbnailer::Files.new('*.png')
thumb.create # creates thumb_<file>.png files

Creating from a PDF file

thumb = Thumbnailer::PDF.new('test.pdf')
thumb.create # creates thumb_<file>_<page>.png files for all pages

Options

We can send some options to customize the output

thumb = Thumbnailer::File.new('ruby-logo.png', prefix: 'custom_thumb_')
thumb.create # creates custom_thumb_ruby-logo.png with 1/10 of the original size

thumb = Thumbnailer::File.new('ruby-logo.png', ratio: 5)
thumb.create # creates thumb_ruby-logo.png with 1/5 of the original size

thumb = Thumbnailer::File.new('ruby-logo.png', dir: '/tmp')
thumb.create # creates thumb_ruby-logo.png on /tmp

thumb = Thumbnailer::File.new('ruby-logo.png', width: 35, height: 35)
thumb.create # creates thumb_ruby-logo.png with 35 x 35 size

thumb = Thumbnailer::PDF.new('test.pdf', page: 2)
thumb.create # creates thumb_<file>_2.png files for page 2

thumb = Thumbnailer::PDF.new('test.pdf', pages: [1, 3])
thumb.create # creates thumb_<file>_<page>.png files for pages 1 and 3

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/taq/thumbnailer.