How can I pipe an image into exiv2 or imagemagick, strip the EXIF tag, and pipe it out to stdout for more manipulation?
I'm hoping for something like:
exiv2 rm - - | md5sum
which would output an image supplied via stdin and calcualte its md5sum.
Alternatively, is there a faster way to do this?
Using exiv2
I was not able to find a way to get
exiv2
to output tostdout
-- it only wants to overwrite the existing file. You could use a smallbash
script to make a temporary file and get the md5 hash of that.image.sh:
You would use it like this:
Using ImageMagick
You can do this using ImageMagick instead by using the
convert
command:Caveat:
I found that stripping an image of EXIF tags using
convert
resulted in a smaller file-size than usingexiv2
. I don't know why this is and what exactly is done differently by these two commands.From
man exiv2
:From
man convert
:Using exiftool
ExifTool by Phil Harvey
You could use
exiftool
(I got the idea from https://stackoverflow.com/a/2654314/3565972):This too, for some reason, produces a slightly different image size from the other two.
Conclusion
Needless to say, all three methods (
exiv2
,convert
,exiftool
) produce outputs with different md5 hashes. Not sure why this is. But perhaps if you pick a method and stick to it, it will be consistent enough for your needs.I tested with NEF file. Seems only exiv2 rm works best.
exiftool
andconvert
can't remove all metadata from .nef FILE.Notice that the output file of
exiv2 rm
can no longer be displayed by most image viewers. But I only need the MD5 hash keeps same after I update any metadata of the .NEF file. It works perfect for me.