LinuxCommandLibrary

gifdiff

Compare two GIF images for differences

TLDR

Check how GIFs differ

$ gifdiff [path/to/first.gif] [path/to/second.gif]
copy

Check if GIFs differ
$ gifdiff --brief [path/to/first.gif] [path/to/second.gif]
copy

SYNOPSIS

gifdiff [options...] reference.gif test.gif [diff.gif]

PARAMETERS

-metric type
    Difference metric (e.g., AE, MAE, MEPP, MSE, PAE, PSNR, RMSE, SSIM)

-fuzz distance
    Tolerance for color similarity (e.g., 10%)

-dissimilarity-threshold value
    Maximum distortion before reporting difference

-highlight-color color
    Color for highlighting differences (default red)

-lowlight-color color
    Color for unchanged pixels in highlight image

-channel type
    Channel to compare (e.g., RGB, Alpha, Gray)

-verbose
    Detailed output including per-frame metrics

-quiet
    Suppress non-error output

-subimage-search
    Search for matching subimages

-density geometry
    Horizontal/vertical resolution for input images

DESCRIPTION

gifdiff is a utility from the ImageMagick suite for detecting differences between two animated GIF files. It compares corresponding frames pairwise, accounting for GIF-specific features like frame delays, disposal methods, and loop counts. Differences are reported textually (frame numbers and bounding boxes) and can be visualized in an optional output GIF where mismatched pixels are highlighted.

The tool uses ImageMagick's compare algorithm under the hood, applying metrics such as root mean squared error (RMSE) or peak absolute error (PAE). If distortion exceeds a threshold, frames are flagged. This makes it ideal for regression testing in web development, animation verification, or CI/CD pipelines for graphics. Single-frame GIFs or static images are supported but primarily shine with animations.

Invocation requires two input GIFs; output defaults to stdout unless specified. Verbose mode provides detailed distortion stats per frame.

CAVEATS

Requires ImageMagick installation. Best for animated GIFs; may ignore disposal methods in some versions. Large animations can be memory-intensive. Outputs text report unless diff file specified.

EXAMPLE USAGE

gifdiff orig.gif new.gif diff.gif
Generates diff.gif highlighting frame differences.

gifdiff -metric RMSE -fuzz 5% -verbose test1.gif test2.gif
Reports RMSE per frame with 5% fuzz tolerance.

OUTPUT FORMAT

Text: Image 1: orig.gif Image 2: new.gif Frame 3: bbox 10x20+50+100 (distortion 0.05)
Visual: Animated GIF with highlighted diffs.

HISTORY

Introduced in ImageMagick 6.3.0 (2007) as a GIF-specific frontend to compare, enhancing animation diffing. Evolved with ImageMagick 7.x for better metric support and performance.

SEE ALSO

compare(1), identify(1), magick(1), animate(1)

Copied to clipboard