magick Verified current stable Not installed? Data Processing

Magick / Compare Images

Compare Images

Compares two images and generates a visual difference file.

$
Terminal
magick compare <image1> <image2> <output>

When To Use

During QA processes for visual regression testing of UI components.

Pro Tip

Use the '-silent' option to suppress standard output but retain errors for debugging.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Comparing images...

Image 1: image1.png
Image 2: image2.png
Output: output_diff.png

Comparison completed. Differences saved to output_diff.png.

Anatomy of Output

Understanding the result

Comparing images: /path/to/image1.png and /path/to/image2.png Comparison Initiation

Indicates which images are being compared.

Difference file created at: /path/to/output.png Output Location

Shows where the visual difference output is stored.

Comparison completed in: 120 ms Timing Info

Duration taken to process the image comparison.

Power User Variants

Optimized versions

magick compare -metric AE image1.png image2.png output.png

Use absolute error metric for comparison.

magick compare -highlight-color red image1.png image2.png output.png

Highlight differences in red during comparison.

Troubleshooting

Common pitfalls

Error: First image not found: 'image1.png'

Solution: Check the file path for the first image.

Error: Second image not found: 'image2.png'

Solution: Check for typos in the second image path.

Error: Output path not writable

Solution: Ensure the output directory has the appropriate write permissions.

Command Breakdown

What each part is doing

magick
Base Command
The executable that performs this operation. Here it runs Magick before the shell applies any redirect operators.

How To Run

Execution path

  1. Step 1

    Run: magick compare image1.png image2.png output_diff.png

  2. Step 2

    Verify output with: ls -lh output_diff.png

  3. Step 3

    Check difference visually using: display output_diff.png

Alternative Approaches

Comparable commands in other tools

Alternative data processing tools for the same job.