diagram
diagram is a tool for manipulating PNG images using imagemagick and the Go image library
Dependencies
- Go
- ImageMagick with Pango support
- on Arch Pango is an optional dependency of ImageMagick, so make sure you also have that installed for creating labels
- elm
Usage
Basic usage
To load a list of captions from capfile
and place them on input.png
run:
$ diagram -cap capfile input.png
Captions
Caption files are of the form
Text Size Xpos,Ypos
Text
is arbitrary text, not including spaces. HTML codes like <sub> and <sup> are passed directly to Pango, but you can also use a LaTeX-style _X, where X is one or more digits (\d+).Size
is the size in pixels of the text for the labelXpos,Ypos
is the x (y) or horizontal (vertical) position of the label in pixels
Flags
For pure commandline usage, the -grid
flag is very helpful for
aligning your captions manually, and the -o
flag allows you to
save the resulting image directly. For interactive use, see the
Web interface section below.
-grid h,v
: draw a grid withh
horizontal andv
vertical divisions of the image-o outfile
: write the resulting image tooutfile
-cap capfile
: take the list of captions from capfile-web
: use the web interface-crop lx,uy,rx,by
: crop the image to the dimensions specified bylx
,uy
,rx
, andby
, which are the left-x, upper-y, right-x, and bottom-y coordinates, respectively-port port
: specify the port to use for the web server, defaults to :8080
Web interface
Since it can be unwieldy to write the captions from scratch, there
is a web interface available via the -web
flag. This starts a
server on localhost:8080 by default, but you can adjust the port
with the -port
flag. After you finish editing the captions, you
can save them to a file for later commandline use. Save the image
by right-clicking and saving the image using your typical browser
facilities.