Middleman ImageOptim Extension

Wat.

Serving big images is for numb-skulls! Compress and optimise your imagery during middleman build by running image_optim over it. Aww yiss!

Build Status Coverage Status Gem Version Dependency Status

Installation

Go set up the image_optim external utilities, then;

gem "middleman-imageoptim", "~> 0.1.4"

Usage

activate :imageoptim

You can also configure the extension in the usual fashion, by passing a block to :activate Below is the default configuration showing all available options;

activate :imageoptim do |options|
  # print out skipped images
  options.verbose = false

  # Setting these to true or nil will let options determine them (recommended)
  options.nice = true
  options.threads = true

  # Image extensions to attempt to compress
  options.image_extensions = %w(.png .jpg .gif)

  # compressor worker options, individual optimisers can be disabled by passing
  # false instead of a hash
  options.pngcrush_options  = {:chunks => ['alla'], :fix => false, :brute => false}
  options.pngout_options    = {:copy_chunks => false, :strategy => 0}
  options.optipng_options   = {:level => 6, :interlace => false}
  options.advpng_options    = {:level => 4}
  options.jpegoptim_options = {:strip => ['all'], :max_quality => 100}
  options.jpegtran_options  = {:copy_chunks => false, :progressive => true, :jpegrescan => true}
  options.gifsicle_options  = {:interlace => false}
end

Changelog

0.1.4
  • Respect plugin ordering in config.rb (thanks @jeffutter) #8
0.1.3
  • fix missing license in gemspec
0.1.2
  • minor bugfix
0.1.1
  • remove legacy requirement for padrino
0.1.0
  • complete refactor and clean-up
  • introduced an options class. options now work (lol, yay!), thanks @andrew-aladev for your help there
  • change of extension activation name from :image_optim to :imageoptim for consistency with internal naming