
Ask: send email if two images are the same - TheSpiceIsLife
Have an issue at work with a laser cutter. It&#x27;s in auto change-over mode, finishes cutting one sheet then swaps it out and cuts the next.<p>Sometimes gets stuck on an error it can&#x27;t recover from. In talks with supplier to update software to handle error.<p>I&#x27;ve got a USB webcam sitting inside the machine capturing a still image every 300 seconds. I want to be able to send an email if the two most recent image captures from the webcam are the same, indicating the machine has stopped, so I know to come in and fix it.<p>Images are being captured on a Windows 7 PC and uploaded to Dropbox. Solution could be any tool on Windows 7, Linux,or MacOS.<p>Any help would be appreciated.
======
sam0x17
Are the two most recent images _actually_ the same, as in a per-pixel match,
or are you going to get random noise from dithering etc? If they are literally
the same, then this becomes a lot easier.

You could easily set up a simple node.js program that uses fs.watcher to watch
for new files, and
[https://github.com/lovell/sharp](https://github.com/lovell/sharp) to process
the two most recent images and see if the pixels are identical. If you need to
package this into a standalone executable, you could use
[https://www.npmjs.com/package/pkg](https://www.npmjs.com/package/pkg). Then
you could use the built-in SMTP sender (if it is not blocked on your network)
or mailgun or something of that nature to send the email.

You can do the same thing in other languages, like ruby, python, etc as well.

If the two images files are literally identical as in the same jpeg with all
the same bytes, you could do this with a bash script that compares the sha1 or
md5 hash of the two files and then consult
[https://stackoverflow.com/questions/5155923/sending-a-
mail-f...](https://stackoverflow.com/questions/5155923/sending-a-mail-from-a-
linux-shell-script) for how to send an email from a bash script.

~~~
TheSpiceIsLife
Thanks for the response, this gives me a bit to go on.

The images are jpg files from iSpy Connect. I'll see take some sample photos
and see if they hash the same.

