When re-generating examples in IM Examples I faced a problem of attempting to determine if a freshly generated example image was the same as the previously generated image.
If they were the same I restored the original one (unless I flagged it not to)
But if they were different (difficult with JPEG and multi image GIF animations) then
notify me they the example had unexpectedly changed.
This system of keeping the original file saves me a LOT of bandwidth when I upload my changes to an intermediate host for collection to use on the offical website. But it has also greatly benefited IM Users when some software change cause unexpected problems, breaking accepted practice. It allowed us to fix new problems before the new update is released.
Of course if a software change, say modified text rendering I can get 50% of all the examples changing in some way, meaning a lot of work seperating the accepted change from a unexpected change.
However in your case it sounds like you want to do the same type of thing. You don't want to replace the old original image if the command did not generate a new image.
The script is hidden but online at
http://www.imagemagick.org/Usage/generate_compare
And basically works like this
The original image is saved by prefixing a underscore.
EG:
mv image.png _image.png
The examples are regenerated to create (or fail to create) a new "image.png"
this script then compares "_image.png" with "image.png" and decided to either restore the old image on no change, or report if a change has happened (if large enough).
its first handles special images (usally text and multi-image GIF animations)
Then checks the image sizes
then the image contents.
Different image formats are handled differently. and that is where the trickiness comes in.
Some images like PNG has a creation date, and that means the image file is always different,
as such I can not simply compare the image files directly.
The image data is thus compared using
compare -metric PAE $new $old null: 2>&1
to get a number on just how different the results are. Usually it is zero, but not always.
For example a jpeg library upgrade could cause minor differences.
That is all I can suggest for you.