使用 .NET 从 JPEG 中删除 EXIF 数据的简单方法
如何从 JPEG 图像中删除所有 EXIF 数据?
我发现了很多关于如何使用各种库读取和编辑 EXIF 数据的示例,但我所需要的只是一个关于如何删除它的简单示例。
它只是为了测试建议,所以即使是最丑陋和最黑客的方法也会有帮助:)
我已经尝试搜索 EXIF 开始/结束标记 0xFFE1 和 0xFFE1 。 0xFFE2。 最后一个在我的例子中不存在。
How can I remove all EXIF data from a JPEG image?
I found lots of examples on how to read and edit the EXIF data with various libraries, but all I would need is a simple example on how to remove it.
It is just for testing proposes, so even the ugliest and hackished approach would be helpful :)
I already tried searching for the EXIF start/end markers 0xFFE1 & 0xFFE2. The last one does not exist in my case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我首先在我的博客中使用 WPF 库撰写了有关此内容的文章,但由于 Windows 后端调用有点混乱,所以这种方式失败了。
我的最终解决方案也快得多,基本上是字节补丁jpeg 以删除 exif。 快速而简单:)
[编辑:博客文章有更多更新的代码]
I first wrote about this using WPF libs in my blog, but this sort of failed since Windows backend calls are a bit messed up.
My final solution is also much quicker which basically byte patches the jpeg in order to remove the exif. Fast and simple :)
[EDIT: Blog post has more updated code]
我认为将文件读入位图对象并再次写入文件应该可以解决问题。
我记得在执行“图像旋转程序”时感到沮丧,因为它删除了 EXIF 数据。 但在这种情况下,这正是您想要的!
I think reading in the file into a Bitmap object and writing out to a file again should do the trick.
I remember feeling frustrated while doing my "image rotation program" that it removed the EXIF data. But in this case, it's exactly what you want!
你应该避免的是解码和重新编码你的图像,因为这会损害质量。 相反,您应该找到一种仅修改元数据的方法。 我还没有尝试过,但我认为 InPlaceBitmapMetadataWriter 就可以了。
what you should avoid is to decode and re-encode your images because this will hurt the quality. instead you should find a way to modify only the metadata. i haven't tried it but i think InPlaceBitmapMetadataWriter will do the trick.
这个问题已经很久了,但最近遇到了一个问题。 这两个函数将从以文件路径或 byte[] 数组形式提供的 JPG 中删除 EXIF 数据,而不需要任何第三方包。
它的工作原理是将图像复制到新的位图。 使用返回的字节数组,您可以调用 context.Response.BinaryWrite 将图像写入响应。
Been a long time since this question but ran into an issue with this recently. These two functions will remove EXIF data from JPG's provided either as a filepath or byte[] array, without needing any third party packages.
It works by copying the image to a new bitmap. With the returned byte array, you can call
context.Response.BinaryWrite
to write the image to the response.这太简单了,从这里使用 jhead.exe: http://www.sentex.net/~mwandel /jhead/
如果需要,制作一个小批处理文件,例如:
jhead.exe -purejpg *.jpg
它将从同一文件夹中的所有 jpeg 中删除所有元数据。
It's too easy, use jhead.exe from here: http://www.sentex.net/~mwandel/jhead/
Make a little batch file if you want e.g.:
jhead.exe -purejpg *.jpg
It will strip all metadata from all jpegs in the same folder.