Easy way to clean metadata from an image?

前端 未结 2 1627
轮回少年
轮回少年 2021-01-07 10:38

I\'m working on a service for a company project that handles image processing, and one of the methods is supposed to clean the metadata from an image passed to it.

I

2条回答
  •  臣服心动
    2021-01-07 11:19

    • The .NET way: You may want to try your hand at the System.Windows.Media.Imaging.BitmapEncoder class - more precisely, its Metadata collection. Quoting MSDN:

    Metadata - Gets or sets the metadata that will be associated with this bitmap during encoding.

    • The 'Oops, I (not so accidentally) forgot something way: Open the original bitmap file into a System.drawing.Bitmap object. Clone it to a new Bitmap object. Write the clone's contents to a new file. Like this one-liner:

      ((System.Drawing.Bitmap)System.Drawing.Image.FromFile(@"C:\file.png").Clone()).Save(@"C:\file-nometa.png");

    • The direct file manipulation way (only for JPEG): Blog post about removing the EXIF area.

提交回复
热议问题