Wednesday, April 24, 2024
HomeJavaScriptThe right way to Create a Diff of Two Pictures

The right way to Create a Diff of Two Pictures


Once I was a baby, I cherished on the lookout for Waldo within the “The place’s Waldo?” ebook collection. Lately I am a sucker for TMZ’s “What is the Huge Frigin Distinction” photographs, the place TMZ barely modifications a picture and it’s important to spot the variations between the 2. That bought me to considering — how simply may I automate diff’ing two photographs? This StackOverflow publish was gold.

To create a diff of two related photographs, we’ll use ImageMagick’s convert command line utility with a big 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 efficient is that this command with its configuration arguments? Let’s take a look:

Unique Picture

Modified Picture

Diff’ed Picture

The diff picture result’s fairly informative! The dimensions of the sun shades is clearly offered, and should you look carefully, you may see one cranium on the top-right of the shirt has been flipped.

No matter your motive for eager to establish the distinction two photographs, ImageMagick’s convert instrument is spectacular. You’ll be able to do one million issues with ImageMagick; try my Media tutorials to be taught extra superior methods to switch photographs, movies, and audio!

  • 5 More HTML5 APIs You Didn’t Know Existed

    The HTML5 revolution has offered us some superior JavaScript and HTML APIs.  Some are APIs we knew we have wanted for years, others are innovative cell and desktop helpers.  No matter API energy or function, something to assist us higher do our job is a…

  • Regular Expressions for the Rest of Us

    Ultimately you will run throughout a daily expression. With their cryptic syntax, complicated documentation and big studying curve, most builders accept copying and pasting them from StackOverflow and hoping they work. However what should you may decode common expressions and harness their energy? In…

  • Fix Anchor URLs Using MooTools 1.2

    The executive management panel I construct for my clients options FCKEditor, a strong WYSIWYG editor that enables the client so as to add hyperlinks, daring textual content, create ordered lists, and so forth. I present coaching and documentation to the shoppers however many occasions they merely neglect to…

  • QuickBoxes for Dojo

    Including to my psychological portfolio is necessary to me. First got here MooTools, then jQuery, and now Dojo. I communicate typically with Peter Higgins of Dojo fame and determined it was time to step into his world. I selected a easy however helpful plugin…


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments