Tuesday, May 21, 2024
HomeTechnologySoftwareHow to Create a Diff of Two Images

How to Create a Diff of Two Images

Date:

Related stories

When Anxious, How Do You Reset?

Throughout my 31 years of life, I’ve found...

GTA 6 Could Be The First Game To Cost More Than $70

It’s only been about two years or so...

Redmi Pad Pro in for review

This is the Redmi Pad Pro and it's...

Iowa Superintendent and Former Olympian Bested in Footrace by 5th-Grader

Phil Roeder, the district’s director of public affairs...
spot_imgspot_img

When I was a child, I loved looking for Waldo in the “Where’s Waldo?” book series. These days I’m a sucker for TMZ’s “What’s the Big Frigin Difference” images, where TMZ slightly changes an image and you have to spot the differences between the two. That got me to thinking — how easily could I automate diff’ing two images? This StackOverflow post was gold.

To create a diff of two similar images, we’ll use ImageMagick’s convert command line utility with a large host of configurations:

convert '(' image1.png -flatten -grayscale Rec709Luminance ')' \
        '(' image2.png -flatten -grayscale Rec709Luminance ')' \
        '(' -clone 0-1 -compose darken -composite ')' \
        -channel RGB -combine diff.png

How effective is this command with its configuration arguments? Let’s have a look:

Original Image

Modified Image

Diff’ed Image

The diff image result is pretty informative! The size of the sunglasses is clearly presented, and if you look closely, you can see one skull at the top-right of the shirt has been flipped.

Whatever your reason for wanting to identify the difference two images, ImageMagick’s convert tool is impressive. You can do a million things with ImageMagick; check out my Media tutorials to learn more awesome ways to modify images, videos, and audio!

  • How I Stopped WordPress Comment Spam

    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database…

  • CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point…



Source link

Latest stories

spot_img