博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
脱敏小软件
阅读量:6976 次
发布时间:2019-06-27

本文共 2091 字,大约阅读时间需要 6 分钟。

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

后续更新具体设计和思路

 项目地址:

/*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    ///  2     /// 删除图像的经纬度信息 3     ///  4     public class ExifUtil 5     { 6         ///  7         /// 删除图像的经纬度信息,覆盖原图像 8         ///  9         /// 文件路径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         /// 24         /// 删除图像的经纬度信息,并另存为25         /// 26         /// 文件路径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         /// 39         /// 删除图像的经纬度信息40         /// 41         /// 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

你可能感兴趣的文章
proc /sys/vm 终结版
查看>>
无锁队列的实现
查看>>
iOS网络高级编程:iPhone和iPad的企业应用开发(书籍学习)
查看>>
Mac 抓包工具 Charles
查看>>
c# 串口编程
查看>>
ListView的可编辑化
查看>>
dedecms的特性-----不完整
查看>>
hdoj1014 互质
查看>>
sizeof(Vector<>)大小问题
查看>>
Python Cookbook 笔记--12章并发编程
查看>>
[转]理解 Delphi 的类(十一) - 深入类中的方法[10] - 构造方法与析构方法
查看>>
5.24
查看>>
DateUtil(2)
查看>>
文件的读取和写出
查看>>
Objective-C Runtime 运行时之三:方法与消息
查看>>
Vijos P1304 回文数【回文+进制】
查看>>
POJ NOI MATH-7826 分苹果
查看>>
内存可见性和原子性:Synchronized和Volatile的比较
查看>>
BAT三家互联网公司哪家更注重用户体验?
查看>>
php-fpm重启失败报错
查看>>