IMGDIFF(1)

πŸ“¦ version 7.44.0, in nixpkgs unstable

πŸ’… IMGDIFF(1) β€” the BRL-CAD girlie's guide to image diffing ✨

okay so bestie, welcome to imgdiff, brought to you by the BRL-CAD fam 🫢. This is the lil tool that looks at two images and tells you exactly how much they disagree, pixel by pixel, channel by channel. No cap. Let's get into it πŸŽ€


✨ NAME ✨

imgdiff β€” compare two images and report or visualize their differences πŸ’–


🌸 SYNOPSIS 🌸

imgdiff [options] img1 img2 [output]

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does imgdiff actually do? It takes two images, img1 and img2, and compares them on a per-channel, per-pixel basis. Then it reports how many channels match exactly, how many differ by one unit, and how many differ by more than one unit. It's giving very meticulous, very detail-oriented, main character energy πŸ‘‘

Input images are read through the libicv image library, which means literally any format libicv understands can be compared β€” we're talking pix(5), bw(5), and PNG, iykyk 🌈. And plot twist that slays: the two inputs don't even need to be the same format. Mix and match, bestie πŸ’…

The image format is normally inferred from each file's extension. For raw formats that carry no embedded dimensions β€” that's pix(5) and bw(5) β€” imgdiff tries to deduce the width and height from the file size. When that fails (😭), you have to supply the dimensions explicitly. No guessing, no vibes, just numbers.

If you give an output path (either with -o or as a third positional argument) and the images differ, a difference image gets written that highlights the disagreeing pixels πŸ”₯. And when PNG render metadata is present, imgdiff can also compare that metadata and emit nirt(1) shotline scripts that re-trace the differing pixels β€” perfect for debugging renders, lowkey iconic.


πŸ’œ OPTIONS πŸ’œ

  • -h, β€”help, -? β€” print a usage summary and dip. That's it, that's the whole option ✌️
  • -o file, β€”output file β€” write the difference image to file. Equivalent to passing output as a third positional argument. ⚠️ Heads up bestie: the file must not already exist. So don't come crying to me if it errors out πŸ™ˆ
  • -n prefix, β€”nirt-output prefix β€” write nirt(1) shotline scripts for the differing pixels. You get one file per image that carries PNG render metadata: prefix\_img1.nirt and/or _prefix\_img2.nirt 🎯
  • β€”width-img1 # β€” width in pixels of the first image. For raw formats lacking embedded size, this is your girl 🫢
  • β€”height-img1 # β€” height in pixels of the first image.
  • β€”width-img2 # β€” width in pixels of the second image.
  • β€”height-img2 # β€” height in pixels of the second image.
  • β€”format-img1 format β€” override the auto-detected file format of the first input image. Because sometimes the extension is lying to you πŸ’€
  • β€”format-img2 format β€” override the auto-detected file format of the second input image.
  • β€”output-format format β€” override the auto-detected file format of the output image.
  • -A, β€”approximate β€” instead of the per-channel report, compute an approximate perceptual difference metric and print the Hamming distance between the two images. It's giving "I don't need the details, just the number" ✨
  • -m, β€”metadata β€” compare embedded render metadata (PNG only) and report whether it's identical or differs. Metadata girlies rise 🌸

πŸ“ EXAMPLES πŸ“

Example 1. Visualize the difference between two renders

imgdiff -o changed.png baseline.png current.png

Compares two PNG renders pixel by pixel, prints how many channels match or differ, and β€” if they differ β€” writes changed.png highlighting exactly which pixels changed πŸ”₯. Super useful for spotting regressions in rt(1) output. Obsessed, honestly.

Example 2. Compare raw pix images of known size and trace differing pixels

imgdiff --width-img1 512 --height-img1 512 \
        --width-img2 512 --height-img2 512 \
        -n shots ref.pix new.pix

Compares two 512x512 pix(5) images whose dimensions cannot be inferred from the file (so we're telling it manually, because we're helpful like that πŸ’…), and β€” for any image carrying render metadata β€” writes nirt(1) shotline scripts (shots_img1.nirt, shots_img2.nirt) that re-fire rays through the differing pixels πŸŽ€


🌈 SEE ALSO 🌈

brlcad(1), nirt(1), rt(1), pix-png(1), pixdiff(1), pix(5), bw(5)

Go read them, they're all part of the same friend group fr fr 🫢


πŸ‘‘ AUTHOR πŸ‘‘

BRL-CAD Team


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


πŸ’Œ BUG REPORTS πŸ’Œ

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org πŸ“§. Not me personally, bestie β€” the devs. They got you πŸ’œ


k that's the whole page!! πŸ¦‹ this gloriousness is IMGDIFF(1) from the BRL-CAD manual β€” mwah, go diff some images, you're gonna slay βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from