Delete all metadata from common image formats?

I am writing a service for a project that will handle our image processing. It is assumed that one of these processes breaks all the metadata from byte[]and returns the same image as byte[].

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

I have not been able to test it yet, but something tells me that I will experience a loss of quality.

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

(bmp, gif, png, jpg, icon, tiff)

I don’t know how I can narrow it down further. It would be nice if I got some feedback regarding downvotes.

+3
source share
1 answer

For a lossless format (except JPEG), your idea is to download it as a bitmap and save it again in order. Not sure if .NET natively supports TIFF (I doubt it is).

For JPEG, as you suggested, there may be a loss of quality if you recompress the file after unpacking it. To do this, you can try ExifLibrary and see if it has anything. If not, there are command line tools (such as ImageMagick) that can strip metadata. (If you use ImageMagick, you are all set up, as it supports all the required formats. The command you want is convert -strip.)

For TIFF.NET has built-in classes TiffBitmapDecoderand ...Encoderthat you could use; see here .

, , ImageMagick, , . , , .NET ( JPEG ).

: , ImageMagick JPEG , . , , , - JPEG, - , .

+2

All Articles