bwrot — rotate, invert, or reverse a black and white bw file


bwrot [ -rifb | -a angle ] [-s squaresize] [-w in_width] [-n in_height] [-o] [] [ > ]


bwrot will rotate, vertically invert, and horizontally reverse a black and white bw(5) format file or read from standard input if a file name is not given. The -w and -n flags specify the input file width and number of scan lines in pixels (both values default to 512); they can be set to same value via -s.

The -r flag reverses the scan lines left to right. The -i flag inverts the image top to bottom. The -f and -b flag will rotate the image ninety degrees forward or backward respectively. The sense of the rotation is relative to a first quadrant coordinate system, i.e. origin lower left, where "forward" means clockwise.

Note that a 180 degree rotation can be obtained by both reversing and inverting.

If the -a flag is used, the image will be rotated counterclockwise by the specified arbitrary angle (in degrees).

The -o option can be used to specify an output file instead of redirecting standard out.


A fairly large buffer is kept in memory so that, file size permitting, the entire rotation can occur without seeking on input or output. In any event, the algorithm is designed to process the input sequentially, so that if any seeking is required, it will happen on output only. If these seeks fail, e.g. the output is a pipe, the user will be told that it needs a file on output. A more general solution to this problem would be to see if seeks can be done on input instead, and switch the algorithm to seek on input only.


brlcad(1), pixrot(1), bwscale(5), bwrect(1), bw(5)


If the file size is very large, excessive seeking may occur on output and the rotation will take a very long time. More complicated algorithms could remedy this.




This software is Copyright (c) 1989-2016 by the United States Government as represented by U.S. Army Research Laboratory.


Reports of bugs or problems should be submitted via electronic mail to <>.