Middleman ImageOptim Extension
Serving big images is for numb-skulls! Compress and optimise your imagery during middleman build
by running image_optim over it. Aww yiss!
Installation
Go set up the image_optim external utilities, then;
Middleman < 4.0
gem 'middleman-imageoptim'
Middleman ≥ 4.0
gem "middleman-imageoptim", :git => "https://github.com/plasticine/middleman-imageoptim", :branch => "master"
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 ||
# Use a build manifest to prevent re-compressing images between builds
.manifest = true
# Silence problematic image_optim workers
.skip_missing_workers = true
# Cause image_optim to be in shouty-mode
.verbose = false
# Setting these to true or nil will let options determine them (recommended)
.nice = true
.threads = true
# Image extensions to attempt to compress
.image_extensions = %w(.png .jpg .gif .svg)
# Compressor worker options, individual optimisers can be disabled by passing
# false instead of a hash
.advpng = { :level => 4 }
.gifsicle = { :interlace => false }
.jpegoptim = { :strip => ['all'], :max_quality => 100 }
.jpegtran = { :copy_chunks => false, :progressive => true, :jpegrescan => true }
.optipng = { :level => 6, :interlace => false }
.pngcrush = { :chunks => ['alla'], :fix => false, :brute => false }
.pngout = { :copy_chunks => false, :strategy => 0 }
.svgo = {}
end
Changelog
0.2.1
- Minor bugfix for 3.3.9 support.
0.2.0
- Big cleanup to codebase.
- More tests.
- Caching between builds using a manifest file to skip over already-compressed assets (thanks for your work on this @jagthedrummer).
- Updates
image_optim
gem to latest version (0.20.2
). - Adds dependency on
image_optim_pack
to ensure that binaries are available.
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.