IMAGDIFF(1)

NAME
imagdiff - compare two image files and writes differences to a third file file.

SYNOPSIS
imagdiff [-h(elp)] [-f fuzz_dist] [-m mode] oldfile newfile deltafile

DESCRIPTION
imagdiff reads in any two image files readable by Imlib2 and write out a "delta" image file that represents the differences between the two files.

OPTIONS

-h  Print help and quit.

-f fuzz_dist
    When performing a grayscale difference analysis, any pixel values within the distance specified by -f option are considered equal. This option has no effect on a color difference analysis. The default value is 1.

-m mode
    Set of the mode of the difference analysis. At present, five modes are available, as described in the MODES section. The default mode is 1.

MODES

1   Grayscale: In this mode, both input images are converted to grayscale. Any pixels that are darker (when comparing old to new) are highlighted in BLUE, and any pixels that are brighter are highlighted in RED. [On a B&W drawing with a white background, this results in additions being highlighted in BLUE, and subtractions being highlighted in RED.] If one of the two input images is missing, a blank all-white image will be created as a substitute.

2   Grayscale (lightened): This works much like the Grayscale analysis of mode 1, except that all unchanged pixels are shifted halfway towards white. This makes it easier to identify changes on an image where the background is predominantly white. If one of the two input images is missing, a blank all-white image will be created as a substitute.

3   Grayscale (darkened): This works much like the Grayscale analysis of mode 1, except that all unchanged pixels are shifted halfway towards black. This makes it easier to identify changes on an image where the background is predominantly black. If one of the two input images is missing, a blank all-black image will be created as a substitute.

4   Color: Here, the differences between the two images are computed on a per-RED, per-GREEN, and per-BLUE basis and are shifted and scaled such that unchanged pixels will show up as 50% gray. If one of the two input images is missing, a blank 50% gray image will be created as a substitute.

5   Color (stretched): Again, differences between the two images are computed on a per-channel and are shifted that unchanged pixels will show up as 50% gray, but here the scaling is maximimized to emphasize differences. If one of the two input images is missing, a blank 50% gray image will be created as a substitute.

NOTES
The compare and gm compare utilities (found within the ImageMagick and GraphicsMagick suites, respectively) can be utilized to perform a similar analysis. However, imagdiff has been optimized for black-and-white images and runs faster because of the underlying Imlib2 engine.

CAVEATS
Metadata found in the input files (including resolution information) is discarded. Also, the Imlib2 export routine makes no attempts at colorspace reduction or otherwise optimizing the output image. If saving to a PNG file, consider using pngrecolor (or even opt-png) to reduce the filesize.

SEE ALSO
compare(1), gm(1), opt-png(1), pngrecolor(1)

COPYRIGHT
Copyright (C) 2019-2026 by Brian Lindholm. This program is free software; you can use it, redistribute it, and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.