卸下常见的图像格式的所有元数据? [英] Remove all metadata from common image formats?

查看:167
本文介绍了卸下常见的图像格式的所有元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为那将处理我们的图像处理项目的服务。一个这样的过程应该剥去提供的字节[] 所有元数据并返回相同的图像作为字节[]

I'm writing a service for a project that's going to handle our image processing. One such process is supposed to strip all metadata from the byte[] provided and return the same image as a byte[].

我目前正在该方法涉及总是图像转换为位图,然后将其转换回原来的格式,并从<$ C返回数据$ C>的MemoryStream 。

The method I'm currently working on involves always converting the image to a Bitmap, then converting it back to the original format and returning the data from a MemoryStream.

我没能还测试,但直觉告诉我,我会遇到一些质量损失。

I haven't been able to test it yet but something tells me I'm going to experience some quality loss.

我怎样才能把任何图像元数据都与一个共同的格式?

How can I remove all metadata from any image with a common format?

(BMP,GIF,PNG,JPG,图标,TIFF)

不知道我怎么可以缩小下来的任何进一步。将是很好,如果我得到有关downvotes一些反馈。

Not sure how I can narrow that down any further. Would be nice if I got some feedback regarding the downvotes.

推荐答案

对于无损格式(JPEG除外),您加载它作为一个位图和重新储蓄是精细的想法。不知道.NET本身支持的TIFF(我怀疑它)。

For the lossless formats (except JPEG), your idea of loading it as a bitmap and re-saving is fine. Not sure if .NET natively supports TIFFs (I doubt it does).

有关JPEG文件,如你所说可能会有质量损失,如果你重新COM pressing pssing后DECOM $ P $文件。对于这一点,你可以尝试 ExifLibrary ,看看是否有有什么。如果不是,有命令行工具(如ImageMagick的),可以剥离的元数据。 (如果你使用ImageMagick的,就这么简单,因为它支持所有的需要的格式。你想要的命令是转换-strip

For JPEGs, as you suggested there may be quality loss if you're re-compressing the file after decompressing it. For that, you might try the ExifLibrary and see if that has anything. If not, there are command line tools (like ImageMagick) that can strip metadata. (If you use ImageMagick, you're all set, since it supports all of your required formats. The command you want is convert -strip.)

有关TIFF格式,.NET已经内置了 TiffBitmapDe codeR ...恩codeR 类你也许可以使用; 看到这里

For TIFFs, .NET has built-in TiffBitmapDecoder and ...Encoder classes you might be able to use; see here.

总之,使用像ImageMagick的外部工具绝对是最简单的解决方案。如果你不能使用外部工具,你几乎可以肯定将需要特殊情况的格式.NET本身并不支持(和有损JPEG)。

In short, using an external tool like ImageMagick is definitely the easiest solution. If you can't use an external tool, you're almost certainly going to need to special-case the formats that .NET doesn't support natively (and the lossy JPEG).

修改:我刚刚读到的ImageMagick的不做无损与JPEG文件剥离的,对不起。我猜我使用上面的链接库,或其他一些JPEG库,是最好的我能想到的。

EDIT: I just read that ImageMagick doesn't do lossless stripping with JPEGs, sorry. I guess using the library I linked above, or some other JPEG library, is the best I can think of.

这篇关于卸下常见的图像格式的所有元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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