【问题标题】:Editing/Remove Exif Image data on Windows Phone在 Windows Phone 上编辑/删除 Exif 图像数据
【发布时间】:2013-06-05 22:23:58
【问题描述】:

我正在使用出色的 ExifLib 从我在 Windows Phone 8 (http://www.codeproject.com/Articles/36342/ExifLib-A-Fast-Exif-Data-Extractor-for-NET-2-0) 上的图像中提取 Exif 数据。但是,由于隐私限制,我需要能够从从用户照片库导入的图像中删除 GPS exif 数据。

很遗憾,我找不到一种方法来轻松编辑或删除这些数据、我缺少的任何指针或库?

任何帮助将不胜感激。

【问题讨论】:

    标签: c# windows-phone-8 windows-phone exif


    【解决方案1】:

    blog post here 展示了如何在不重新编码图像的情况下删除 EXIF 数据。帖子中的代码

    using System.IO;
    
    namespace ExifRemover
    {
        public class JpegPatcher
        {
            public Stream PatchAwayExif(Stream inStream, Stream outStream)
            {
                byte[] jpegHeader = new byte[2];
                jpegHeader[0] = (byte)inStream.ReadByte();
                jpegHeader[1] = (byte)inStream.ReadByte();
                if (jpegHeader[0] == 0xff && jpegHeader[1] == 0xd8) //check if it's a jpeg file
                {
                    SkipAppHeaderSection(inStream);
                }
                outStream.WriteByte(0xff);
                outStream.WriteByte(0xd8);
    
                int readCount;
                byte[] readBuffer = new byte[4096];
                while ((readCount = inStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
                    outStream.Write(readBuffer, 0, readCount);
    
                return outStream;
            }
    
            private void SkipAppHeaderSection(Stream inStream)
            {
                byte[] header = new byte[2];
                header[0] = (byte)inStream.ReadByte();
                header[1] = (byte)inStream.ReadByte();
    
                while (header[0] == 0xff && (header[1] >= 0xe0 && header[1] <= 0xef))
                {
                    int exifLength = inStream.ReadByte();
                    exifLength = exifLength << 8;
                    exifLength |= inStream.ReadByte();
    
                    for (int i = 0; i < exifLength - 2; i++)
                    {
                        inStream.ReadByte();
                    }
                    header[0] = (byte)inStream.ReadByte();
                    header[1] = (byte)inStream.ReadByte();
                }
                inStream.Position -= 2; //skip back two bytes
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-11-17
      • 1970-01-01
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-20
      • 2015-02-22
      相关资源
      最近更新 更多