65.9K
CodeProject 正在变化。 阅读更多。
Home

ExifTagCollection - EXIF 元数据提取库

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.87/5 (42投票s)

2008年6月25日

CPOL

4分钟阅读

viewsIcon

421285

downloadIcon

10420

一个用于从图像中提取 EXIF 信息的库,符合 EXIF 2.2 标准。

引言

该库的灵感来自于 Asim GoheerExifExtractor 类。ExifExtractor 的问题在于它不支持 EXIF 2.2 标准中定义的一些标签,例如与 GPS 数据相关的标签,因此我决定修改它,但最终决定从头开始重写,尽管我重用了一些 Asim 的代码。

ExifTagsCollection 基于 IEnumerable<T>,并包含一个 ExifTag 类的集合,该类封装了 EXIF 标签。

ExifTag 类包含给定标签的字段名称、描述、ID 和值。已添加了几个方便的类

  • Rational - 用于有符号有理数值
  • URational - 用于无符号有理数值
  • GPSRational - 用于 GPS 24 位数据

使用代码

使用该代码非常简单。这是一个在控制台中列出所有标签的示例

// See other constructors, for creating ExifTagCollection with Image instance, etc.
ExifTagCollection exif = new ExifTagCollection(@"c:\somefile.jpg");

foreach (ExifTag tag in exif)
    Console.Out.WriteLine(tag);

另一个通过 ID 获取特定标签的示例

ExifTagCollection exif = new ExifTagCollection(@"c:\somefile.jpg");

ExifTag tag = exif[2];
Console.Out.WriteLine(tag);
//OUTPUT: Latitude (GPSLatitude) = 22° 47' 35,35"

支持的 EXIF 字段

  • ImageWidth - 图像宽度
  • ImageHeight - 图像高度
  • GPSVersionID - GPS 标签版本
  • GPSAltitudeRef - 高度参考
  • StripOffsets - 图像数据位置
  • RowsPerStrip - 每条带的行数
  • StripByteCounts - 每条压缩带的字节数
  • PixelXDimension - 有效图像宽度
  • PixelYDimension - 有效图像高度
  • BitsPerSample - 每个分量的位数
  • Compression - 压缩方案
  • PhotometricInterpretation - 像素构成
  • Orientation - 图像方向
  • SamplesPerPixel - 分量数
  • PlanarConfiguration - 图像数据排列
  • YCbCrSubSampling - Y 与 C 的子采样率
  • YCbCrPositioning - Y 和 C 的位置
  • ResolutionUnit - X 和 Y 分辨率的单位
  • TransferFunction - 传递函数
  • ColorSpace - 色彩空间信息
  • ExposureProgram - 曝光程序
  • ISOSpeedRatings - ISO 速度等级
  • MeteringMode - 测光模式
  • LightSource - 光源
  • Flash - 闪光灯
  • SubjectArea - 主体区域
  • FocalPlaneResolutionUnit - 焦平面分辨率单位
  • SubjectLocation - 主体位置
  • SensingMethod - 感光方法
  • CustomRendered - 自定义图像处理
  • ExposureMode - 曝光模式
  • WhiteBalance - 白平衡
  • FocalLengthIn35mmFilm - 35 毫米胶片焦距
  • SceneCaptureType - 场景捕获类型
  • Contrast - 对比度
  • Saturation - 饱和度
  • Sharpness - 锐度
  • SubjectDistanceRange - 主体距离范围
  • GPSDifferential - GPS 差分校正
  • ShutterSpeedValue - 快门速度
  • BrightnessValue - 亮度
  • ExposureBiasValue - 曝光补偿
  • JPEGInterchangeFormat - JPEG SOI 的偏移量
  • JPEGInterchangeFormatLength - JPEG 数据字节数
  • XResolution - 宽度方向的图像分辨率
  • YResolution - 高度方向的图像分辨率
  • WhitePoint - 白点色度
  • PrimaryChromaticities - 基色色度
  • YCbCrCoefficients - 色彩空间变换矩阵系数
  • ReferenceBlackWhite - 黑色和白色参考值对
  • CompressedBitsPerPixel - 图像压缩模式
  • ExposureTime - 曝光时间
  • FNumber - F 值
  • ApertureValue - 光圈值
  • MaxApertureValue - 最大镜头光圈
  • SubjectDistance - 主体距离
  • FocalLength - 镜头焦距
  • FlashEnergy - 闪光灯能量
  • FocalPlaneXResolution - 焦平面 X 分辨率
  • FocalPlaneYResolution - 焦平面 Y 分辨率
  • ExposureIndex - 曝光指数
  • DigitalZoomRatio - 数码变焦比
  • GainControl - 增益控制
  • GPSLatitude - 纬度
  • GPSLongitude - 经度
  • GPSAltitude - 高度
  • GPSTimeStamp - GPS 时间(原子钟)
  • GPSDOP - 测量精度
  • GPSSpeed - GPS 接收器速度
  • GPSTrack - 行进方向
  • GPSImgDirection - 图像方向
  • GPSDestLatitude - 目的地纬度
  • GPSDestLongitude - 目的地经度
  • GPSDestBearing - 目的地方位角
  • GPSDestDistance - 到目的地的距离
  • DateTime - 文件修改日期和时间
  • ImageDescription - 图像标题
  • Make - 图像输入设备制造商
  • Model - 图像输入设备型号
  • Software - 使用的软件
  • Artist - 图像创建者
  • Copyright - 版权持有者
  • RelatedSoundFile - 相关音频文件
  • DateTimeOriginal - 原始数据生成日期和时间
  • DateTimeDigitized - 数字数据生成日期和时间
  • SubSecTime - DateTime 的亚秒部分
  • SubSecTimeOriginal - DateTimeOriginal 的亚秒部分
  • SubSecTimeDigitized - DateTimeDigitized 的亚秒部分
  • ImageUniqueID - 唯一图像 ID
  • SpectralSensitivity - 光谱灵敏度
  • GPSLatitudeRef - 北纬或南纬
  • GPSLongitudeRef - 东经或西经
  • GPSSatellites - 用于测量的 GPS 卫星
  • GPSStatus - GPS 接收器状态
  • GPSMeasureMode - GPS 测量模式
  • GPSSpeedRef - 速度单位
  • GPSTrackRef - 行进方向参考
  • GPSImgDirectionRef - 图像方向参考
  • GPSMapDatum - 使用的大地测量数据
  • GPSDestLatitudeRef - 目的地纬度参考
  • GPSDestLongitudeRef - 目的地经度参考
  • GPSDestBearingRef - 目的地方位角参考
  • GPSDestDistanceRef - 到目的地距离参考
  • GPSDateStamp - GPS 日期
  • OECF - 光电转换因子
  • SpatialFrequencyResponse - 空间频率响应
  • FileSource - 文件来源
  • SceneType - 场景类型
  • CFAPattern - CFA 模式
  • DeviceSettingDescription - 设备设置描述
  • ExifVersion - EXIF 版本
  • FlashpixVersion - 支持的 Flashpix 版本
  • ComponentsConfiguration - 每个分量的含义
  • MakerNote - 制造商注释
  • UserComment - 用户注释
  • GPSProcessingMethod - GPS 处理方法名称
  • GPSAreaInformation - GPS 区域名称

历史

  • 初始发布。
© . All rights reserved.