IMGDIMS(1)
π
IMGDIMS(1) β the imgdims girlies' guide π
okay so real talk: imgdims is that friend who can look at any image file and be like "yeah that's 512 512, trust" β it guesses the width and height of an image in pixels, no cap. It's part of BRL-CAD, and it's genuinely so useful, bestie. Let's get into it β¨
πΈ NAME πΈ
imgdims β guess the width and height of an image file π¦
β¨ SYNOPSIS β¨
imgdims [-n | -s] [-# bytes_per_pixel] file_name
imgdims [-# bytes_per_pixel] num_bytes
π DESCRIPTION π
So here's the vibe: imgdims guesses the dimensions of an image β width and height, in pixels π. It computes the total pixel count and hands that off to the framebuffer common-image-size autosizing routines, which come back with the most plausible width and height for that count. It's giving "trust the process" and honestly, the process delivers π
.
You can tell it the image size in one of two ways, and both are iconic in their own right:
- Implicitly β give it a file_name, and it reads the byte size with
stat(2)π«Ά - Explicitly β give it num_bytes as a positive integer instead of a file
Then the byte count gets divided by the bytes-per-pixel value to get the pixel count. Important: it has to divide evenly, or imgdims exits with an error π β no messy leftovers allowed, periodt.
By default imgdims uses the file size to guess. But with -n it first tries to read the dimensions encoded in the file name itself (as written by tools such as pix-fb(1) and fb-pix(1)), falling back to the file size if the name carries no usable resolution. iykyk π
The result prints to standard output as two space-separated numbers, like this:
width height
That's it. That's the whole deliverable. Iconic π
π OPTIONS π
-nβ Believe the file name π. It tries to extract the dimensions straight out of file_name if that name encodes a standard BRL-CAD resolution (e.g. an embedded1024x768). If the name carries no usable resolution, it falls back to guessing from the file size. Lowkey the bestie who trusts your word first.-sβ Believe the stat π«Ά. Ignores any dimensions encoded in the file name and uses the file size in bytes to determine the pixel count and guess the width and height. This is the default behavior. Very "numbers don't lie" of it.-# bytes_per_pixelβ Specify the size of each pixel in bytes, as a positive integer π. Common values are1(black-and-white images) and3(RGB images). If omitted, the pixel size is taken from the file extension (.bw=1,.pix=3); any unrecognized extension, or an explicit num_bytes argument, defaults to3. Not me checking the file extension like it's a personality test π-h,-?β Print usage information and exit β¨. The universal "wait, how do I do this again" escape hatch.
π¦ EXAMPLES π¦
Example 1. Guess the dimensions of a .pix image and feed them to a viewer πΈ
imgdims teapot.pix
# prints e.g. "512 512"
pix-fb -w 512 -n 512 teapot.pix
imgdims reads the byte size of teapot.pix, divides by 3 (the default for .pix), and reports the width and height autosizing chose for that pixel count β which you can then pass straight to pix-fb(1) to display the image. Look at you, chaining commands like a main character π
β¨
Example 2. Recover the resolution from a tool-generated file name π
imgdims -n moss_1024x1024.bw
With -n, imgdims pulls the 1024x1024 resolution straight out of the file name rather than inferring it from the file size. That's reliable even when the byte count is ambiguous between several common resolutions β i.e. when the math girlies could go either way, the filename just tells you π
Example 3. Size a raw black-and-white buffer given only its byte count π
imgdims -# 1 262144
No file involved here at all, bestie: 262144 bytes at 1 byte per pixel is 262144 pixels, for which autosizing reports 512 512. Pure math, no file system, slay π₯
π SEE ALSO π
brlcad(1), pix-fb(1), fb-pix(1), pixdiff(1) β go read those too, they're the extended universe π«Ά
π AUTHOR π
BRL-CAD Team π
β COPYRIGHT β
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory. (Yes, the actual U.S. Government. Not me being dramatic for once. π)
π BUG REPORTS π
Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org π§ β be nice, be specific, and include the details, bestie π§
ngl, the whole tool is basically "trust me, it's probably 512 512" but with actual math behind it. No cap. π
and that's the page!! brought to you by BRL-CAD (no date on this one, so like... forever-current, we love an evergreen manual π) β mwah, go guess some dimensions πβ¨π¦
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms