img provides a bunch of image manipulation tools.
To install the img you will need at least Go 1, follow the installation instructions if you don't already have it. Then installing img is as easy as running,
$ go get hawx.me/code/img
See Using img in Go for help using this programmatically.
Each img tool expects an input image to be passed from STDIN
and prints the result to STDOUT
, for example
$ img greyscale < input.png > output.png
This makes it easy to chain multiple commands together using pipes,
$ (img greyscale | img pxl | img contrast --factor 2) \
< input.png > output.png
img can be extended with external scripts. They must be named img-something
and be somewhere on the PATH
to be found.
The first argument will always be an indicator of the expected output format. This should, if possible, be the format output by the tool. It will be one of either png
, jpeg
or tiff
.
They are then expected to respond to the following flags:
something [args]
. The first word will be used as the command's name.img help
listing.img help something
. This should follow the format of the other tools: the description should be indented two spaces; arguments should be indented four spaces, with a hash separating the description.You can see examples in the hawx/img-ext repo. And learn more about Using img in Go.