imgdims — guess the width and height of an image file


imgdims [-ns ] [-# bytes_per_pixel] file_name


imgdims [-# bytes_per_pixel] num_bytes


imgdims uses the autosizing capability of libbn(5) to guess the dimensions (in pixels) of an image. The image size may be expressed either implicitly, by specifying the name of the file; or explicitly, by specifying a number of bytes.

The -n option specifies that the dimensions should be extracted directly from file_name, in the form of any of the standard BRL-CAD command-line options. Given the -s option, imgdims ignores any dimensions encoded in file_name and uses the size of the file in bytes to compute the number of pixels in the image and then guess the image's width and height. The -# option specifies the size of each pixel (in bytes).

If file_name is specified with neither of the -s and -n options, imgdims tries to extract the dimensions from file_name, and if that fails it computes the image size and guesses the width and height. If the -# option is not specified, imgdims determines the pixel size based on the extension on file_name. If, additionally, num_bytes was specified or file_name contains none of the recognized extensions, imgdims assumes that there are 3-byte-wide pixels.




Paul Tanenbaum


This software is Copyright (c) 1997-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 <>.