2

I have many images, each roughly 10000 x 40 pixels, visualizing graphs that are mostly chains with a few spurs and other "decorations." (They're made by piping OpenFST's fstdraw through Graphviz's dot).

From the command line, how can I automatically brute-force rearrange one of these skinny images to readably fit on a 1920x1080 screen? For instance, split the image into pieces at most 1920 pixels long, and then stack them vertically.

Something using ImageMagick's convert -crop in a loop?

Here's what fails:

  • Replacing dot with one of its sisters neato, fdp, etc. At least fdp outputs a non-skinny image, but only because the skinny graph randomly twists and overlaps like a frickin' chromosome. The image is still mostly white, the labels are unreadably tiny, and the structure is just a squiggle.

  • Adding the option ratio=1 to dot's input merely pads 10000x40 to 10000x10000.

1 Answers1

1

Because 10000/1920 rounds up to 6, split the input into 6 pieces left-to-right, and glue them back together top to bottom. Instead of using 6 intermediate files, use a format which holds multiple images (tiff is much faster than gif), and stdin and stdout.

convert in.png -crop 6x1@ +repage tiff:- | convert tiff:- -append out.png