Exif.js 提供了 JavaScript 讀取圖像的原始數據的功能擴展,例如:拍照方向、相機設備型號、拍攝時間、ISO 感光度、GPS 地理位置等數據。
- 注意事項:
-
EXIF 數據主要來自拍攝的照片,多用於移動端開發,PC 端也會用到,此插件兼容主流瀏覽器,IE10 以下不支持。
在線實例
實例預覽 簡單示例
實例預覽 獲取 base64 編碼文件數據
實例預覽 異步獲取圖像數據
使用方法
載入 JavaScript 文件
- <script src="exif.js"></script>
復制
獲取 EXIF 數據
EXIF.getData(document.getElementById('imgElement'), function(){
EXIF.getAllTags(this);
EXIF.getTag(this, 'Orientation');
});
復制
API 方法
名稱 | 說明 |
---|---|
EXIF.getData(img, callback) | 獲取圖像的數據 能兼容尚未支持提供 EXIF 數據的瀏覽器獲取到元數據。 |
EXIF.getTag(img, tag) | 獲取圖像的某個數據 |
EXIF.getAllTags(img) | 獲取圖像的全部數據,值以對象的方式返回 |
EXIF.pretty(img) | 獲取圖像的全部數據,值以字符串的方式返回 |
EXIF 標識
名稱 | 說明 |
---|---|
ExifVersion | Exif 版本 |
FlashPixVersion | FlashPix 版本 |
ColorSpace | 色域、色彩空間 |
PixelXDimension | 圖像的有效寬度 |
PixelYDimension | 圖像的有效高度 |
ComponentsConfiguration | 圖像構造 |
CompressedBitsPerPixel | 壓縮時每像素色彩位 |
MakerNote | 制造商設置的信息 |
UserComment | 用戶評論 |
RelatedSoundFile | 關聯的聲音文件 |
DateTimeOriginal | 創建時間 |
DateTimeDigitized | 數字化創建時間 |
SubsecTime | 日期時間(秒) |
SubsecTimeOriginal | 原始日期時間(秒) |
SubsecTimeDigitized | 原始日期時間數字化(秒) |
ExposureTime | 曝光時間 |
FNumber | 光圈值 |
ExposureProgram | 曝光程序 |
SpectralSensitivity | 光譜靈敏度 |
ISOSpeedRatings | 感光度 |
OECF | 光電轉換功能 |
ShutterSpeedValue | 快門速度 |
ApertureValue | 鏡頭光圈 |
BrightnessValue | 亮度 |
ExposureBiasValue | 曝光補償 |
MaxApertureValue | 最大光圈 |
SubjectDistance | 物距 |
MeteringMode | 測光方式 |
Lightsource | 光源 |
Flash | 閃光燈 |
SubjectArea | 主體區域 |
FocalLength | 焦距 |
FlashEnergy | 閃光燈強度 |
SpatialFrequencyResponse | 空間頻率反應 |
FocalPlaneXResolution | 焦距平面X軸解析度 |
FocalPlaneYResolution | 焦距平面Y軸解析度 |
FocalPlaneResolutionUnit | 焦距平面解析度單位 |
SubjectLocation | 主體位置 |
ExposureIndex | 曝光指數 |
SensingMethod | 圖像傳感器類型 |
FileSource | 源文件 |
SceneType | 場景類型(1 == 直接拍攝) |
CFAPattern | CFA 模式 |
CustomRendered | 自定義圖像處理 |
ExposureMode | 曝光模式 |
WhiteBalance | 白平衡(1 == 自動,2 == 手動) |
DigitalZoomRation | 數字變焦 |
FocalLengthIn35mmFilm | 35毫米膠片焦距 |
SceneCaptureType | 場景拍攝類型 |
GainControl | 場景控制 |
Contrast | 對比度 |
Saturation | 飽和度 |
Sharpness | 銳度 |
DeviceSettingDescription | 設備設定描述 |
SubjectDistanceRange | 主體距離范圍 |
InteroperabilityIFDPointer | |
ImageUniqueID | 圖像唯一ID |
名稱 | 說明 |
---|---|
ImageWidth | 圖像寬度 |
ImageHeight | 圖像高度 |
BitsPerSample | 比特采樣率 |
Compression | 壓縮方法 |
PhotometricInterpretation | 像素合成 |
Orientation | 拍攝方向 |
SamplesPerPixel | 像素數 |
PlanarConfiguration | 數據排列 |
YCbCrSubSampling | 色相抽樣比率 |
YCbCrPositioning | 色相配置 |
XResolution | X方向分辨率 |
YResolution | Y方向分辨率 |
ResolutionUnit | 分辨率單位 |
StripOffsets | 圖像資料位置 |
RowsPerStrip | 每帶行數 |
StripByteCounts | 每壓縮帶比特數 |
JPEGInterchangeFormat | JPEG SOI 偏移量 |
JPEGInterchangeFormatLength | JPEG 比特數 |
TransferFunction | 轉移功能 |
WhitePoint | 白點色度 |
PrimaryChromaticities | 主要色度 |
YCbCrCoefficients | 顏色空間轉換矩陣系數 |
ReferenceBlackWhite | 黑白參照值 |
DateTime | 日期和時間 |
ImageDescription | 圖像描述、來源 |
Make | 生產者 |
Model | 型號 |
Software | 軟件 |
Artist | 作者 |
Copyright | 版權信息 |
名稱 | 說明 |
---|---|
GPSVersionID | GPS 版本 |
GPSLatitudeRef | 南北緯 |
GPSLatitude | 緯度 |
GPSLongitudeRef | 東西經 |
GPSLongitude | 經度 |
GPSAltitudeRef | 海拔參照值 |
GPSAltitude | 海拔 |
GPSTimeStamp | GPS 時間戳 |
GPSSatellites | 測量的衛星 |
GPSStatus | 接收器狀態 |
GPSMeasureMode | 測量模式 |
GPSDOP | 測量精度 |
GPSSpeedRef | 速度單位 |
GPSSpeed | GPS 接收器速度 |
GPSTrackRef | 移動方位參照 |
GPSTrack | 移動方位 |
GPSImgDirectionRef | 圖像方位參照 |
GPSImgDirection | 圖像方位 |
GPSMapDatum | 地理測量資料 |
GPSDestLatitudeRef | 目標緯度參照 |
GPSDestLatitude | 目標緯度 |
GPSDestLongitudeRef | 目標經度參照 |
GPSDestLongitude | 目標經度 |
GPSDestBearingRef | 目標方位參照 |
GPSDestBearing | 目標方位 |
GPSDestDistanceRef | 目標距離參照 |
GPSDestDistance | 目標距離 |
GPSProcessingMethod | GPS 處理方法名 |
GPSAreaInformation | GPS 區功能變數名 |
GPSDateStamp | GPS 日期 |
GPSDifferential | GPS 修正 |