使用exiv2或imagemagick从stdin中删除EXIF数据并输出到stdout [英] Use exiv2 or imagemagick to remove EXIF data from stdin and output to stdout

查看:557
本文介绍了使用exiv2或imagemagick从stdin中删除EXIF数据并输出到stdout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将图像传输到exiv2或imagemagick,剥离EXIF标记,并将其传输到标准输出以进行更多操作?

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

将输出通过stdin提供的图像并计算其md5sum。

which would output an image supplied via stdin and calcualte its md5sum.

或者,有更快的方法吗?

Alternatively, is there a faster way to do this?

推荐答案

使用exiv2



我无法找到一种方法来获得 exiv2 输出到 stdout - 它只想覆盖现有文件。您可以使用一个小的 bash 脚本来创建一个临时文件并获取该文件的md5哈希。

Using exiv2

I was not able to find a way to get exiv2 to output to stdout -- it only wants to overwrite the existing file. You could use a small bash script to make a temporary file and get the md5 hash of that.

image.sh

#!/bin/bash
cat <&0 > tmp.jpg  # Take input on stdin and dump it to temp file.
exiv2 rm tmp.jpg   # Remove EXIF tags in place.
md5sum tmp.jpg     # md5 hash of stripped file.
rm tmp.jpg         # Remove temp file.

您可以这样使用它:

cat image.jpg | image.sh



使用ImageMagick



你可以使用ImageMagick而不是使用 convert 命令来执行此操作:

Using ImageMagick

You can do this using ImageMagick instead by using the convert command:

cat image.jpg | convert -strip - - | md5sum

警告:

我发现使用 convert 剥离EXIF标记的图像导致文件大小小于使用 exiv2 。我不知道为什么会这样,这两个命令究竟做了什么不同。

I found that stripping an image of EXIF tags using convert resulted in a smaller file-size than using exiv2. I don't know why this is and what exactly is done differently by these two commands.

来自 man exiv2


rm      从文件中删除图像元数据。

rm        Delete image metadata from the files.

man convert


-strip      所有个人资料和评论的条形图

-strip        strip image of all profiles and comments



使用exiftool



Phil Harvey的ExifTool

你可以使用 exiftool (我从 https:// stackoverflow得到了这个想法.com / a / 2654314/3565972 ):

cat image.jpg | exiftool -all= - -out - | md5sum

由于某种原因,这也会产生与其他两个图像尺寸略有不同的图像尺寸。

This too, for some reason, produces a slightly different image size from the other two.

毋庸置疑,所有三种方法( exiv2 转换 exiftool )生成具有不同md5哈希值的输出。不知道为什么会这样。但也许如果你选择一种方法并坚持下去,它将足以满足你的需求。

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.

这篇关于使用exiv2或imagemagick从stdin中删除EXIF数据并输出到stdout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆