【问题标题】:Get ImageUniqueID in .tiff images获取 .tiff 图像中的 ImageUniqueID
【发布时间】:2016-11-10 10:37:29
【问题描述】:

通过以下代码片段,我获得了 .jpg 图像的 UniqueImageId。但是相同的代码不适用于 .tiff 文件。有人有想法吗?谢谢

Image myImage = new Bitmap(@"C:\path\to\picture.tiff");
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
PropertyItem pi = myImage.GetPropertyItem(42016);   // EXIF-Code -> UniqueImageID
string uniqueImageId = encoding.GetString(pi.Value, 0, 32);

【问题讨论】:

    标签: c# .net image metadata


    【解决方案1】:

    我的解决方案:

    string uniqueImageId;
    Tiff mytiff = Tiff.Open(absolutePath, "r");
    FieldValue[] exifIFDTag = mytiff.GetField(TiffTag.EXIFIFD);
    int exifIFDOffset = exifIFDTag[0].ToInt();
    mytiff.ReadEXIFDirectory(exifIFDOffset);
    FieldValue[] value = mytiff.GetField(TiffTag.EXIF_IMAGEUNIQUEID);
    if (value != null)
    {
        for (int i = 0; i < value.Length; i++)
        {
            uniqueImageId = value[i].ToString();
        }
    
    }
    mytiff.Close();
    

    【讨论】:

      猜你喜欢
      • 2011-11-17
      • 2017-09-16
      • 1970-01-01
      • 2012-07-04
      • 2022-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多