Image Manipulation w/ Ruby
For the next version of PT, we’ll most likely be needing different thumbnail sizes to reflect the needs of the design. The current PT is written in PHP, but PT is going to be written in Ruby going forward (alpha.patterntap.com is already written in Rails), so I decided to take a gander as what’s out their for image manipulation in Ruby.
For raw image manipulation, there is RMagick, ImageScience and MiniMagick. I may end up using one of those directly, but most likely I’ll be using a higher-level library that provides more functionality (storage to S3, accepting uploads, etc) in addition to just image manipulation. For these types of libraries, there is Paperclip (most people’s go-to), CarrierWave, and Dragonfly (awesome on-the-fly capabilities). All of those libraries have their pros/cons, but I decided to play around with CarrierWave a bit since I haven’t used it before.
Outside of handling uploads and storage, CarrierWave does have some nice wrappers around ImageMagick functions that I wanted to play around with.
I used this script to play around with CarrierWave.
Here are some before and after shots of a couple of images using resize_to_fill.
Before:
After:
Before:
After:



