Project

photile

0.0
No commit activity in last 3 years
No release in over 3 years
Photile is just a layer on top of Imagemagick and Jpegtran to make certain image processing tasks dead simple.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.8.7
>= 2.3.6
 Project Readme

photile

photile can be used to power a web widget like turnandzoom or just about any simple image processing workflow. With photile you can run simple tasks like compression, watermarking and tiling images manually or in an automated fashion. These tasks can be combined to formulate a custom flow. For example, you can compress an imagewatermark itbreak it up into tiles.

One scenario where this is really useful is image processing for product images. Most product images are shot on white background, which means that there is a big opportunity to reduce image size and improve rendering speed on the web page. Here's what you can do with photile: basic quality reductionwatermark your product imagesbreak it up into tiles (certain tiles will be all white)compress individual tiles.

Installation & Dependencies

  • Imagemagick - Follow the installation instructions here (on Linux you can install it using: sudo apt-get install imagemagick imagemagick-common).
  • Jpegtran - Follow the installation instructions here (on Linux you can install it using: sudo apt-get install libjpeg-turbo-progs).
# https://rubygems.org/gems/gem
$ gem install photile

Examples

# Usage
$ photile
Usage: photile [options] infile outfile
    -q, --quality VALUE              Modify image quality
    -c, --compress                   Loss-less compress image
    -w, --watermark FILE             Watermark with given file
    -t, --tile WIDTHxHEIGHT          Tile to the given dimensions
    -v, --verbose                    Run verbosely
    -h, --help                       Display options help
        --version                    Show version

# Basic Examples
$ photile --quality 80 image-in image-out
$ photile --compress image-in image-out
$ photile --watermark image-watermark image-in image-out
$ photile --tile WIDTHxHEIGHT image-in image-out

# Advanced Examples

# 1. Reduce quality and then loss less compression for 'image-in' to produce 'image-out'
$ photile --quality 80 --compress image-in image-out

# 2. Watermark 'image-in' with 'image-watermark' and then tile it with size 'WIDTHxHEIGHT' to produce '[image-out-0...image-out-n]'
$ photile --watermark image-watermark --tile WIDTHxHEIGHT image-in image-out

# 3. Reduce quality % of 'image-in', then compress it and watermark it with 'image-watermark'. Finally, tile the watermarked image to produce '[image-out-0...image-out-n]'
$ photile --quality QUALITY --compress --watermark image-watermark --tile WIDTHxHEIGHT image-in image-out

Features

The four main functions of photile can be used in all combinations possible because of their 'piping' properties (i.e., the Builder Pattern). Each function takes in an image and spits out an image or an array of images. When an array of images is returned any function thereafter is applied to all items in the array. When piping functions the order is relevant as the output of a function becomes the input of another. For example: tilewatermark (tiles images and then applies a watermark to the smaller, chopped images) is not the same as watermarktile (watermarks an image and then creates tiles).

Here are the piping scenarios available

  • Quality manipulation: IMAGEQuality ModifierIMAGE
  • Loss-less compression: IMAGECompressorIMAGE
  • Watermarking: IMAGE + WATERMARK IMAGEWatermarkerIMAGE
  • Tiling: IMAGETiler[IMAGE...IMAGE]

More

Photile uses the amazing Imagemagick 6.6.9-7 and Jpegtran 1.2.0 libraries. Imagemagick provides quality, watermarking and tiling properties. Jpegtran provides the loss-less compression. In other words, photile is just a layer on top of existing libraries to make certain image processing tasks dead simple. Additionally since photile is a gem it can be used directly in Rails to create dynamic workflows.

TODO

  • Documentation
  • Use log4r for logging
  • More unit tests to ensure that all pipe permutations work
  • Sign gem on deploy
  • Use from rake/ruby scripts and from rails

Copyright (c) 2013 Nitin Dhar. See MIT-LICENSE for details.