img

img provides a bunch of image manipulation tools.

Installation

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.

Usage

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

Tools

External Tools

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:

--usage
The usage string, eg. something [args]. The first word will be used as the command's name.
--short
A short, one-line description of the tool to show in the img help listing.
--long
A long, multi-line description shown in 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.