Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taq/thumbnailer
Easy way to create thumbnails from images and PDF files
https://github.com/taq/thumbnailer
Last synced: 1 day ago
JSON representation
Easy way to create thumbnails from images and PDF files
- Host: GitHub
- URL: https://github.com/taq/thumbnailer
- Owner: taq
- Created: 2017-04-17T19:48:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T15:29:09.000Z (over 7 years ago)
- Last Synced: 2024-11-10T02:41:02.123Z (5 days ago)
- Language: Ruby
- Size: 167 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Thumbnailer
A simple way to create thumbnails.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'thumbnailer'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install thumbnailer
## Usage
### Creating from a file
```ruby
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
```ruby
thumb = Thumbnailer::Files.new('*.png')
thumb.create # creates thumb_.png files
```## Creating from a PDF file
```ruby
thumb = Thumbnailer::PDF.new('test.pdf')
thumb.create # creates thumb__.png files for all pages
```#### Options
We can send some options to customize the output
```ruby
thumb = Thumbnailer::File.new('ruby-logo.png', prefix: 'custom_thumb_')
thumb.create # creates custom_thumb_ruby-logo.png with 1/10 of the original sizethumb = Thumbnailer::File.new('ruby-logo.png', ratio: 5)
thumb.create # creates thumb_ruby-logo.png with 1/5 of the original sizethumb = Thumbnailer::File.new('ruby-logo.png', dir: '/tmp')
thumb.create # creates thumb_ruby-logo.png on /tmpthumb = Thumbnailer::File.new('ruby-logo.png', width: 35, height: 35)
thumb.create # creates thumb_ruby-logo.png with 35 x 35 sizethumb = Thumbnailer::PDF.new('test.pdf', page: 2)
thumb.create # creates thumb__2.png files for page 2thumb = Thumbnailer::PDF.new('test.pdf', pages: [1, 3])
thumb.create # creates thumb__.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](https://rubygems.org).## Contributing
Bug reports and pull requests are welcome on GitHub at
https://github.com/taq/thumbnailer.