zoukankan      html  css  js  c++  java
  • 脱敏小软件

    通过修改图像文件的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     }
  • 相关阅读:
    修改 PHP 最大运行时间 max_execution_time
    去除桌面的不可清理的恶意图标
    SQL 性能调优 set statistics io
    SQL Server 2008 Failover Cluster
    [转]SQLSERVER数据存储内幕
    博客开通
    Entity FrameWork 4.3 实体属性为decimal时默认只保存2位小数
    FreeBSD常用命令及配置
    动态加载JS或CSS
    JS获取传入该页面的参数
  • 原文地址:https://www.cnblogs.com/xinyf/p/10106746.html
Copyright © 2011-2022 走看看