脱敏小软件

通过修改图像文件的Exif信息中经纬度信息,使图像数据脱敏

后续更新具体设计和思路

 项目地址:https://gitee.com/SmallUniv/ExifTool

/*PropertyItem 中对应属性
    参考资料:https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.propertyitem.id?redirectedfrom=MSDN&view=netframework-4.7.2#System_Drawing_Imaging_PropertyItem_Id
     * ID    Property tag
       0x0000    PropertyTagGpsVer
       0x0001    PropertyTagGpsLatitudeRef
       0x0002    PropertyTagGpsLatitude
       0x0003    PropertyTagGpsLongitudeRef
       0x0004    PropertyTagGpsLongitude
       0x0005    PropertyTagGpsAltitudeRef
       0x0006    PropertyTagGpsAltitude
     */

 

 

 1    /// <summary>
 2     /// 删除图像的经纬度信息
 3     /// </summary>
 4     public class ExifUtil
 5     {
 6         /// <summary>
 7         /// 删除图像的经纬度信息,覆盖原图像
 8         /// </summary>
 9         /// <param name="IN_File">文件路径</param>
10         public void DeleteCoord(string IN_File)
11         {
12             using (Stream ms = new MemoryStream(File.ReadAllBytes(IN_File)))
13             {
14                 using (Image image = Image.FromStream(ms))
15                 {
16                     DeleteCoordInfo(image);
17                     image.Save(IN_File);
18                 }
19             }
20         }
21 
22         
23         /// <summary>
24         /// 删除图像的经纬度信息,并另存为
25         /// </summary>
26         /// <param name="IN_File">文件路径</param>
27         public void DeleteCoord(string IN_File, string IN_Save)
28         {
29             using (Stream ms = new MemoryStream(File.ReadAllBytes(IN_File)))
30             {
31                 using (Image image = Image.FromStream(ms))
32                 {
33                     DeleteCoordInfo(image);
34                     image.Save(IN_Save);
35                 }
36             }
37         }
38         /// <summary>
39         /// 删除图像的经纬度信息
40         /// </summary>
41         /// <param name="image"></param>
42         public static void DeleteCoordInfo(Image image)
43         {
44             int[] ids = new[] { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006 };
45             foreach (int id in ids)
46             {
47                 if (image.PropertyIdList.Contains(id))
48                 {
49                     image.RemovePropertyItem(id);
50                 }
51             }
52         }
53     }

 

转载于:https://www.cnblogs.com/xinyf/p/10106746.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值