Skip to content

Artie18/optipng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Ruby Optipng Interface

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages