Project

optipng-r

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby interface to 'optipng' tool.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 1.5.2

Runtime

 Project Readme

Optipng

Gem Version

Optipng provides Ruby interface to the optipng tool. Some examples follow: (for details, see module documentation)

require "optipng"

Optipng.available?        # will return true (or false)

Optipng.optimize(["foo.png", "empty.png", "nonexist.png"], { :level => 5 })

# will run 'optipng -o 5 foo.png bar.png empty.png'
# and then will return for example:
#   '#<struct Optipng::Result succeed={"foo.png => -22.1}}, errors=[["empty.png", "Unrecognized image file format"], ["nonexist.png", "Can't open the input file"]]>

It can be also run asynchronously by non-blocking way (with [eventmachine][4]) simply by giving block with one argument to #optimize. See documentation.

Call Result

Result contains members :success and :errors. Sucess member contains hash of successfully optimized files with ratio as value. Zero or positive percent ratio means the same as file has been skipped so already optimized. It's negative number against the number reported by optipng so it means new size against the old size.

Errors contains array with pairs where first member of the pair is filename and second the message. First one can be null if message isn't strictly associated with concrete file. (But fortunately usually it is.)

Contributing

  1. Fork it.
  2. Create a branch (git checkout -b 20101220-my-change).
  3. Commit your changes (git commit -am "Added something").
  4. Push to the branch (git push origin 20101220-my-change).
  5. Create an Issue with a link to your branch.
  6. Enjoy a refreshing Orange Juice and wait.

Copyright

This gem was originaly developed by [Martin Kozák][https://github.com/martinkozak/optipng]. But original gem is broken, so this is the rebirth of it.

Copyright © 2015 Artyom Fedenko. See LICENSE.txt for further details.