Oil

github.com/ender672/oil

DESCRIPTION:

Oil resizes JPEG and PNG images. It aims for fast performance and low memory use.

INSTALLATION:

$ gem install oil

SYNOPSIS:

require 'oil'
io = File.open('image.jpg', 'rb')

# prepare to resize JPEG to fit in a 200x300 box, preserving aspect ratio
jpeg = Oil::JPEG.new(io, 200, 300)

# yield successive parts of the resized and compressed JPEG file
jpeg.each { |data| }

REQUIREMENTS:

These requirements do not apply to the JRuby gem.

  • IJG JPEG Library or libjpeg-turbo.

  • libpng

Installing libjpeg headers (OSX):

$ brew install libjpeg # requires homebrew (http://mxcl.github.com/homebrew/)

Installing libjpeg and libpng headers (Debian/Ubuntu):

$ sudo apt-get install libjpeg-dev libpng-dev

COMPILING & TESTING:

Compile & run unit tests. Should show no warnings and no failing tests:

$ rake compile
$ rake test

Valgrind should not complain (ruby-1.9.3p125, compiled with -O3):

$ valgrind /path/to/ruby -Iext:test test/test_jpeg.rb
$ valgrind --suppressions=test/valgrind_suppressions.txt /path/to/ruby -Iext:test test/test_png.rb

Tests should not leak memory:

$ ruby -Iext:test -e "require 'test_jpeg.rb'; require 'test_png.rb'; loop{ MiniTest::Unit.new.run }"

Changes to the interpolator should be analyzed using ResampleScope:

https://github.com/jsummers/resamplescope

TODO:

  • Windows

LICENSE:

(The MIT License)

Copyright © 2012

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.