imageExifReader/dist/imageExifReader.min.js
2025-01-03 19:36:25 +08:00

1 line
2.6 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ImageExifReader=t():e.ImageExifReader=t()}(this,(()=>(()=>{"use strict";var e={704:(e,t,r)=>{r.d(t,{default:()=>o}),e=r.hmd(e);class i{constructor(){this.tags={256:"ImageWidth",257:"ImageHeight",274:"Orientation",306:"DateTime",271:"Make",272:"Model",296:"ResolutionUnit",282:"XResolution",283:"YResolution",531:"YCbCrPositioning",34665:"ExifIFDPointer",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",37510:"UserComment",41989:"FocalLengthIn35mmFilm",42016:"ImageUniqueID",42033:"SerialNumber",42034:"LensInfo",42035:"LensMake",42036:"LensModel",42037:"LensSerialNumber"},this.tagTypes={Make:"string",Model:"string",DateTime:"datetime",DateTimeOriginal:"datetime",DateTimeDigitized:"datetime",ExposureTime:"exposuretime",FNumber:"fnumber",FocalLength:"focallength",ISOSpeedRatings:"number",LensModel:"string",LensSerialNumber:"string",XResolution:"resolution",YResolution:"resolution"}}readExifData(e,t){try{const r=new FileReader;r.onerror=()=>t(new Error("文件读取失败")),r.onload=r=>{try{const i=this.parseExif(r.target.result,e.type);t(null,i)}catch(e){t(e)}},r.readAsArrayBuffer(e)}catch(e){t(e)}}parseExif(e,t){const r=new DataView(e),i={};try{switch(t){case"image/jpeg":case"image/jpg":if(65496!==r.getUint16(0,!1))throw new Error("不是有效的 JPEG 图片");let e=2;for(;e<r.byteLength;){const t=r.getUint16(e,!1);if(e+=2,65505===t){const t=r.getUint16(e,!1);if("Exif"===this.getStringFromBuffer(r,e+2,4)){const t=e+8,o=19789===r.getUint16(t,!1);if(42===r.getUint16(t+2,!o)){const e=r.getUint32(t+4,!o);e>0&&this.readIFD(r,t+e,!o,i)}}e+=t}else{if(65498===t)break;e+=r.getUint16(e,!1)}}break;case"image/tiff":this.parseTiffHeader(r,i)}return this.validateData(i)?i:{}}catch(e){return{}}}}e.exports&&(e.exports=i);const o=i;"undefined"!=typeof window&&(window.ImageExifReader=i)}},t={};function r(i){var o=t[i];if(void 0!==o)return o.exports;var n=t[i]={id:i,loaded:!1,exports:{}};return e[i](n,n.exports,r),n.loaded=!0,n.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i=r(704);return i.default})()));