@mapcatch/util 1.0.8-b → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/dist/catchUtil.min.esm.js +1 -1
- package/dist/catchUtil.min.js +1 -1
- package/package.json +1 -1
- package/src/exif/index.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1058,7 +1058,7 @@ const Dy = function(t) {
|
|
|
1058
1058
|
return a;
|
|
1059
1059
|
}, zv = (t) => new Promise((n, i) => {
|
|
1060
1060
|
if (t.type === "image/jpeg") {
|
|
1061
|
-
let f = t.slice(0,
|
|
1061
|
+
let f = t.slice(0, 524288);
|
|
1062
1062
|
f.name = t.name, wy(f, function(s, l) {
|
|
1063
1063
|
if (l) {
|
|
1064
1064
|
i(l);
|
package/dist/catchUtil.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(ir,di){typeof exports=="object"&&typeof module<"u"?di(exports):typeof define=="function"&&define.amd?define(["exports"],di):(ir=typeof globalThis<"u"?globalThis:ir||self,di(ir.catchUtil={}))})(this,function(ir){"use strict";const di={imageHasData(t){return!!t.exifdata},getStringFromDB(t,n,i){for(var a="",f=n;f<n+i;f++)a+=String.fromCharCode(t.getUint8(f));return a},xml2Object(t){try{var n={};if(t.children.length>0)for(var i=0;i<t.children.length;i++){var a=t.children.item(i),f=a.attributes;for(var s in f){var l=f[s],d=l.nodeName,v=l.nodeValue;d!==void 0&&(n[d]=v)}var I=a.nodeName;if(typeof n[I]>"u")n[I]=this.xml2json(a);else{if(typeof n[I].push>"u"){var B=n[I];n[I]=[],n[I].push(B)}n[I].push(this.xml2json(a))}}else n=t.textContent;return n}catch(p){console.log(p.message)}},xml2json(t){var n={};if(t.nodeType==1){if(t.attributes.length>0){n["@attributes"]={};for(var i=0;i<t.attributes.length;i++){var a=t.attributes.item(i);n["@attributes"][a.nodeName]=a.nodeValue}}}else if(t.nodeType==3)return t.nodeValue;if(t.hasChildNodes())for(var f=0;f<t.childNodes.length;f++){var s=t.childNodes.item(f),l=s.nodeName;if(n[l]==null)n[l]=this.xml2json(s);else{if(n[l].push==null){var d=n[l];n[l]=[],n[l].push(d)}n[l].push(this.xml2json(s))}}return n},objectURLToBlob(t,n){var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="blob",i.onload=function(a){(this.status==200||this.status===0)&&n(this.response)},i.send()},base64ToArrayBuffer(t,n){n=n||t.match(/^data\:([^\;]+)\;base64,/mi)[1]||"",t=t.replace(/^data\:([^\;]+)\;base64,/gmi,"");for(var i=atob(t),a=i.length,f=new ArrayBuffer(a),s=new Uint8Array(f),l=0;l<a;l++)s[l]=i.charCodeAt(l);return f}},X_={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},q_={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},zf={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}},K_={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},j_=new TextDecoder,$r=(t,n=0,i=t.length)=>j_.decode(t.slice(n,i)),Bs=(t,n=0,i=t.length)=>t.slice(n,i).reduce((a,f)=>a+("0"+f.toString(16)).slice(-2),""),S0=(t,n=0)=>{const i=t[n]+t[n+1]*256;return i|(i&2**15)*131070},su=(t,n=0)=>t[n]*2**8+t[n+1],ti=(t,n=0)=>t[n]+t[n+1]*2**8,A0=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16,Q_=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16+(t[n+3]<<24),bn=(t,n=0)=>t[n]*2**24+t[n+1]*2**16+t[n+2]*2**8+t[n+3],Ko=(t,n=0)=>t[n]+t[n+1]*2**8+t[n+2]*2**16+t[n+3]*2**24,J_={readUInt16BE:su,readUInt16LE:ti,readUInt32BE:bn,readUInt32LE:Ko};function Ui(t,n,i,a){i=i||0;const f=a?"BE":"LE",s="readUInt"+n+f;return J_[s](t,i)}function ep(t,n){if(t.length-n<4)return;const i=bn(t,n);if(!(t.length-n<i))return{name:$r(t,4+n,8+n),offset:n,size:i}}function jo(t,n,i){for(;i<t.length;){const a=ep(t,i);if(!a)break;if(a.name===n)return a;i+=a.size}}const tp={validate:t=>$r(t,0,2)==="BM",calculate:t=>({height:Math.abs(Q_(t,22)),width:Ko(t,18)})},rp=1,np=2+2+2,ip=1+1+1+1+2+2+4+4;function T0(t,n){const i=t[n];return i===0?256:i}function E0(t,n){const i=np+n*ip;return{height:T0(t,i+1),width:T0(t,i)}}const D0={validate(t){const n=ti(t,0),i=ti(t,4);return n!==0||i===0?!1:ti(t,2)===rp},calculate(t){const n=ti(t,4),i=E0(t,0);if(n===1)return i;const a=[i];for(let f=1;f<n;f+=1)a.push(E0(t,f));return{height:i.height,images:a,width:i.width}}},ap=2,op={validate(t){const n=ti(t,0),i=ti(t,4);return n!==0||i===0?!1:ti(t,2)===ap},calculate:t=>D0.calculate(t)},sp={validate:t=>Ko(t,0)===542327876,calculate:t=>({height:Ko(t,12),width:Ko(t,16)})},fp=/^GIF8[79]a/,lp={validate:t=>fp.test($r(t,0,6)),calculate:t=>({height:ti(t,8),width:ti(t,6)})},up={avif:"avif",mif1:"heif",msf1:"heif",heic:"heic",heix:"heic",hevc:"heic",hevx:"heic"},cp={validate(t){const n=$r(t,4,8),i=$r(t,8,12);return n==="ftyp"&&i in up},calculate(t){const n=jo(t,"meta",0),i=n&&jo(t,"iprp",n.offset+12),a=i&&jo(t,"ipco",i.offset+8),f=a&&jo(t,"ispe",a.offset+8);if(f)return{height:bn(t,f.offset+16),width:bn(t,f.offset+12),type:$r(t,8,12)};throw new TypeError("Invalid HEIF, no size found")}},hp=4+4,dp=4,vp=4,_p={ICON:32,"ICN#":32,"icm#":16,icm4:16,icm8:16,"ics#":16,ics4:16,ics8:16,is32:16,s8mk:16,icp4:16,icl4:32,icl8:32,il32:32,l8mk:32,icp5:32,ic11:32,ich4:48,ich8:48,ih32:48,h8mk:48,icp6:64,ic12:32,it32:128,t8mk:128,ic07:128,ic08:256,ic13:256,ic09:512,ic14:512,ic10:1024};function L0(t,n){const i=n+vp;return[$r(t,n,i),bn(t,i)]}function R0(t){const n=_p[t];return{width:n,height:n,type:t}}const pp={validate:t=>$r(t,0,4)==="icns",calculate(t){const n=t.length,i=bn(t,dp);let a=hp,f=L0(t,a),s=R0(f[0]);if(a+=f[1],a===i)return s;const l={height:s.height,images:[s],width:s.width};for(;a<i&&a<n;)f=L0(t,a),s=R0(f[0]),a+=f[1],l.images.push(s);return l}},mp={validate:t=>Bs(t,0,4)==="ff4fff51",calculate:t=>({height:bn(t,12),width:bn(t,8)})},gp={validate(t){if(bn(t,4)!==1783636e3||bn(t,0)<1)return!1;const n=jo(t,"ftyp",0);return n?bn(t,n.offset+4)===1718909296:!1},calculate(t){const n=jo(t,"jp2h",0),i=n&&jo(t,"ihdr",n.offset+8);if(i)return{height:bn(t,i.offset+8),width:bn(t,i.offset+12)};throw new TypeError("Unsupported JPEG 2000 format")}},yp="45786966",xp=2,Xc=6,bp=2,wp="4d4d",Sp="4949",C0=12,Ap=2;function Tp(t){return Bs(t,2,6)===yp}function Ep(t,n){return{height:su(t,n),width:su(t,n+2)}}function Dp(t,n){const a=Xc+8,f=Ui(t,16,a,n);for(let s=0;s<f;s++){const l=a+Ap+s*C0,d=l+C0;if(l>t.length)return;const v=t.slice(l,d);if(Ui(v,16,0,n)===274)return Ui(v,16,2,n)!==3||Ui(v,32,4,n)!==1?void 0:Ui(v,16,8,n)}}function Lp(t,n){const i=t.slice(xp,n),a=Bs(i,Xc,Xc+bp),f=a===wp;if(f||a===Sp)return Dp(i,f)}function Rp(t,n){if(n>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(t[n]!==255)throw new TypeError("Invalid JPG, marker table corrupted")}const Cp={validate:t=>Bs(t,0,2)==="ffd8",calculate(t){t=t.slice(4);let n,i;for(;t.length;){const a=su(t,0);if(Tp(t)&&(n=Lp(t,a)),Rp(t,a),i=t[a+1],i===192||i===193||i===194){const f=Ep(t,a+5);return n?{height:f.height,orientation:n,width:f.width}:f}t=t.slice(a+2)}throw new TypeError("Invalid JPG, no size found")}},Op={validate:t=>{const n=$r(t,1,7);return["KTX 11","KTX 20"].includes(n)},calculate:t=>{const n=t[5]===49?"ktx":"ktx2",i=n==="ktx"?36:20;return{height:Ko(t,i+4),width:Ko(t,i),type:n}}},Ip=`PNG\r
|
|
2
2
|
|
|
3
|
-
`,Mp="IHDR",O0="CgBI",Fp={validate(t){if(Ip===$r(t,1,8)){let n=$r(t,12,16);if(n===O0&&(n=$r(t,28,32)),n!==Mp)throw new TypeError("Invalid PNG");return!0}return!1},calculate(t){return $r(t,12,16)===O0?{height:bn(t,36),width:bn(t,32)}:{height:bn(t,20),width:bn(t,16)}}},I0={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"},M0={default:t=>{let n=[];for(;t.length>0;){const i=t.shift();if(i[0]!=="#"){n=i.split(" ");break}}if(n.length===2)return{height:parseInt(n[1],10),width:parseInt(n[0],10)};throw new TypeError("Invalid PNM")},pam:t=>{const n={};for(;t.length>0;){const i=t.shift();if(i.length>16||i.charCodeAt(0)>128)continue;const[a,f]=i.split(" ");if(a&&f&&(n[a.toLowerCase()]=parseInt(f,10)),n.height&&n.width)break}if(n.height&&n.width)return{height:n.height,width:n.width};throw new TypeError("Invalid PAM")}},kp={validate:t=>$r(t,0,2)in I0,calculate(t){const n=$r(t,0,2),i=I0[n],a=$r(t,3).split(/[\r\n]+/);return(M0[i]||M0.default)(a)}},Pp={validate:t=>$r(t,0,4)==="8BPS",calculate:t=>({height:bn(t,14),width:bn(t,18)})},F0=/<svg\s([^>"']|"[^"]*"|'[^']*')*>/,fu={height:/\sheight=(['"])([^%]+?)\1/,root:F0,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/},qc=2.54,k0={in:96,cm:96/qc,em:16,ex:8,m:96/qc*100,mm:96/qc/10,pc:96/72/12,pt:96/72,px:1},Np=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(k0).join("|")})?$`);function lu(t){const n=Np.exec(t);if(!!n)return Math.round(Number(n[1])*(k0[n[2]]||1))}function Bp(t){const n=t.split(" ");return{height:lu(n[3]),width:lu(n[2])}}function Gp(t){const n=t.match(fu.width),i=t.match(fu.height),a=t.match(fu.viewbox);return{height:i&&lu(i[2]),viewbox:a&&Bp(a[2]),width:n&&lu(n[2])}}function Up(t){return{height:t.height,width:t.width}}function Yp(t,n){const i=n.width/n.height;return t.width?{height:Math.floor(t.width/i),width:t.width}:t.height?{height:t.height,width:Math.floor(t.height*i)}:{height:n.height,width:n.width}}const Hp={validate:t=>F0.test($r(t,0,1e3)),calculate(t){const n=$r(t).match(fu.root);if(n){const i=Gp(n[0]);if(i.width&&i.height)return Up(i);if(i.viewbox)return Yp(i,i.viewbox)}throw new TypeError("Invalid SVG")}},zp={validate(t){return ti(t,0)===0&&ti(t,4)===0},calculate(t){return{height:ti(t,14),width:ti(t,12)}}};function Wp(t,n){const i=Ui(t,32,4,n);return t.slice(i+2)}function Vp(t,n){const i=Ui(t,16,8,n);return(Ui(t,16,10,n)<<16)+i}function $p(t){if(t.length>24)return t.slice(12)}function Zp(t,n){const i={};let a=t;for(;a&&a.length;){const f=Ui(a,16,0,n),s=Ui(a,16,2,n),l=Ui(a,32,4,n);if(f===0)break;l===1&&(s===3||s===4)&&(i[f]=Vp(a,n)),a=$p(a)}return i}function Xp(t){const n=$r(t,0,2);if(n==="II")return"LE";if(n==="MM")return"BE"}const qp=["49492a00","4d4d002a"],Kp={validate:t=>qp.includes(Bs(t,0,4)),calculate(t){const n=Xp(t)==="BE",i=Wp(t,n),a=Zp(i,n),f=a[256],s=a[257];if(!f||!s)throw new TypeError("Invalid Tiff. Missing tags");return{height:s,width:f}}};function jp(t){return{height:1+A0(t,7),width:1+A0(t,4)}}function Qp(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function Jp(t){return{height:S0(t,8)&16383,width:S0(t,6)&16383}}const em={validate(t){const n=$r(t,0,4)==="RIFF",i=$r(t,8,12)==="WEBP",a=$r(t,12,15)==="VP8";return n&&i&&a},calculate(t){const n=$r(t,12,16);if(t=t.slice(20,30),n==="VP8X"){const a=t[0],f=(a&192)===0,s=(a&1)===0;if(f&&s)return jp(t);throw new TypeError("Invalid WebP")}if(n==="VP8 "&&t[0]!==47)return Jp(t);const i=Bs(t,3,6);if(n==="VP8L"&&i!=="9d012a")return Qp(t);throw new TypeError("Invalid WebP")}},uu=new Map([["bmp",tp],["cur",op],["dds",sp],["gif",lp],["heif",cp],["icns",pp],["ico",D0],["j2c",mp],["jp2",gp],["jpg",Cp],["ktx",Op],["png",Fp],["pnm",kp],["psd",Pp],["svg",Hp],["tga",zp],["tiff",Kp],["webp",em]]),tm=Array.from(uu.keys()),rm=new Map([[56,"psd"],[66,"bmp"],[68,"dds"],[71,"gif"],[73,"tiff"],[77,"tiff"],[82,"webp"],[105,"icns"],[137,"png"],[255,"jpg"]]);function nm(t){const n=t[0],i=rm.get(n);return i&&uu.get(i).validate(t)?i:tm.find(a=>uu.get(a).validate(t))}const im={disabledTypes:[]};function P0(t){var i;const n=nm(t);if(typeof n<"u"){if(im.disabledTypes.indexOf(n)>-1)throw new TypeError("disabled file type: "+n);const a=uu.get(n).calculate(t);if(a!==void 0)return a.type=(i=a.type)!=null?i:n,a}throw new TypeError("unsupported file type: "+n)}var am=!1;const om=function(t,n){return(self.Image&&t instanceof self.Image||self.HTMLImageElement&&t instanceof self.HTMLImageElement)&&!t.complete?(n(null,new Error("\u4E0D\u652F\u6301\u7684\u683C\u5F0F")),!1):(di.imageHasData(t)?n&&n(t):sm(t,n),!0)};function sm(t,n){function i(l){try{var d=fm(l);t.exifdata=d||{};var v;n&&n(t)}catch(I){n(null,I)}}if(t.src)if(/^data\:/i.test(t.src)){var a=di.base64ToArrayBuffer(t.src);i(a)}else if(/^blob\:/i.test(t.src)){var f=new FileReader;f.onload=function(l){i(l.target.result)},di.objectURLToBlob(t.src,function(l){f.readAsArrayBuffer(l)})}else{var s=new XMLHttpRequest;s.onload=function(){if(this.status==200||this.status===0)i(s.response);else throw"Could not load image";s=null},s.open("GET",t.src,!0),s.responseType="arraybuffer",s.send(null)}else if(self.FileReader&&(t instanceof self.Blob||t instanceof self.File)){var f=new FileReader;f.onload=function(d){i(d.target.result)},f.readAsArrayBuffer(t)}}function fm(t){var n=new DataView(t);let i={};for(var a=2,f=t.byteLength,s;a<f&&n.getUint8(a)==255;){if(s=n.getUint8(a+1),s==225){i=lm(n,a+4,n.getUint16(a+2)-2);break}a+=2+n.getUint16(a+2)}let l=P0(new Uint8Array(t));return Object.assign(i,{PixelXDimension:l.width,PixelYDimension:l.height}),i}function JS(t){if("DOMParser"in self){var n=new DataView(t);if(n.getUint8(0)!=255||n.getUint8(1)!=216)return!1;for(var i=2,a=t.byteLength,f=new DOMParser;i<a-4;)if(di.getStringFromDB(n,i,4)=="http"){var s=i-1,l=n.getUint16(i-2)-1,d=di.getStringFromDB(n,s,l),v=d.indexOf("xmpmeta>")+8;d=d.substring(d.indexOf("<x:xmpmeta"),v);var I=d.indexOf("x:xmpmeta")+10;d=d.slice(0,I)+'xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" xmlns:ext="http://www.gettyimages.com/xsltExtension/1.0" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/" xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" '+d.slice(I);var B=f.parseFromString(d,"text/xml");return di.xml2Object(B)}else i++}}function lm(t,n){if(di.getStringFromDB(t,n,4)!="Exif")return!1;var i,a,f,s,l,d=n+6;if(t.getUint16(d)==18761)i=!1;else if(t.getUint16(d)==19789)i=!0;else return!1;if(t.getUint16(d+2,!i)!=42)return!1;var v=t.getUint32(d+4,!i);if(v<8)return!1;if(a=Kc(t,d,d+v,X_,i),a.ExifIFDPointer){s=Kc(t,d,d+a.ExifIFDPointer,q_,i);for(f in s){switch(f){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":s[f]=zf[f][s[f]];break;case"ExifVersion":case"FlashpixVersion":s[f]=String.fromCharCode(s[f][0],s[f][1],s[f][2],s[f][3]);break;case"ComponentsConfiguration":s[f]=zf.Components[s[f][0]]+zf.Components[s[f][1]]+zf.Components[s[f][2]]+zf.Components[s[f][3]];break}a[f]=s[f]}}if(a.GPSInfoIFDPointer){l=Kc(t,d,d+a.GPSInfoIFDPointer,K_,i);for(f in l){switch(f){case"GPSVersionID":l[f]=l[f][0]+"."+l[f][1]+"."+l[f][2]+"."+l[f][3];break}a[f]=l[f]}}return a}function Kc(t,n,i,a,f){var s=t.getUint16(i,!f),l={},d,v,I;for(I=0;I<s;I++)d=i+I*12+2,v=a[t.getUint16(d,!f)],l[v]=um(t,d,n,i,f);return l}function um(t,n,i,a,f){var s=t.getUint16(n+2,!f),l=t.getUint32(n+4,!f),d=t.getUint32(n+8,!f)+i,v,I,B,p,U,q;switch(s){case 1:case 7:if(l==1)return t.getUint8(n+8,!f);for(v=l>4?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint8(v+p);return I;case 2:return v=l>4?d:n+8,di.getStringFromDB(t,v,l-1);case 3:if(l==1)return t.getUint16(n+8,!f);for(v=l>2?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint16(v+2*p,!f);return I;case 4:if(l==1)return t.getUint32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getUint32(d+4*p,!f);return I;case 5:if(l==1)return U=t.getUint32(d,!f),q=t.getUint32(d+4,!f),B=new Number(U/q),B.numerator=U,B.denominator=q,B;for(I=[],p=0;p<l;p++)U=t.getUint32(d+8*p,!f),q=t.getUint32(d+4+8*p,!f),I[p]=new Number(U/q),I[p].numerator=U,I[p].denominator=q;return I;case 9:if(l==1)return t.getInt32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+4*p,!f);return I;case 10:if(l==1)return t.getInt32(d,!f)/t.getInt32(d+4,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+8*p,!f)/t.getInt32(d+4+8*p,!f);return I}}const cm=function(t){if(!di.imageHasData(t))return{};var n,i=t.exifdata,a={};for(n in i)i.hasOwnProperty(n)&&(a[n]=i[n]);return a},jc=t=>new Promise((n,i)=>{if(t.type==="image/jpeg"){let f=t.slice(0,131072);f.name=t.name,om(f,function(s,l){if(l){i(l);return}let d=cm(s),v=JSON.parse(JSON.stringify(d).replaceAll("\\u0000",""))||{};n(v)})}else{var a=new FileReader;a.onload=function(f){let s=new Uint8Array(f.target.result),l=P0(s);n({PixelXDimension:l.width,PixelYDimension:l.height})},a.readAsArrayBuffer(t)}});let cu;const hm=new Uint8Array(16);function dm(){if(!cu&&(cu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!cu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cu(hm)}const Bn=[];for(let t=0;t<256;++t)Bn.push((t+256).toString(16).slice(1));function vm(t,n=0){return(Bn[t[n+0]]+Bn[t[n+1]]+Bn[t[n+2]]+Bn[t[n+3]]+"-"+Bn[t[n+4]]+Bn[t[n+5]]+"-"+Bn[t[n+6]]+Bn[t[n+7]]+"-"+Bn[t[n+8]]+Bn[t[n+9]]+"-"+Bn[t[n+10]]+Bn[t[n+11]]+Bn[t[n+12]]+Bn[t[n+13]]+Bn[t[n+14]]+Bn[t[n+15]]).toLowerCase()}const N0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _m(t,n,i){if(N0.randomUUID&&!n&&!t)return N0.randomUUID();t=t||{};const a=t.random||(t.rng||dm)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){i=i||0;for(let f=0;f<16;++f)n[i+f]=a[f];return n}return vm(a)}//! moment.js
|
|
3
|
+
`,Mp="IHDR",O0="CgBI",Fp={validate(t){if(Ip===$r(t,1,8)){let n=$r(t,12,16);if(n===O0&&(n=$r(t,28,32)),n!==Mp)throw new TypeError("Invalid PNG");return!0}return!1},calculate(t){return $r(t,12,16)===O0?{height:bn(t,36),width:bn(t,32)}:{height:bn(t,20),width:bn(t,16)}}},I0={P1:"pbm/ascii",P2:"pgm/ascii",P3:"ppm/ascii",P4:"pbm",P5:"pgm",P6:"ppm",P7:"pam",PF:"pfm"},M0={default:t=>{let n=[];for(;t.length>0;){const i=t.shift();if(i[0]!=="#"){n=i.split(" ");break}}if(n.length===2)return{height:parseInt(n[1],10),width:parseInt(n[0],10)};throw new TypeError("Invalid PNM")},pam:t=>{const n={};for(;t.length>0;){const i=t.shift();if(i.length>16||i.charCodeAt(0)>128)continue;const[a,f]=i.split(" ");if(a&&f&&(n[a.toLowerCase()]=parseInt(f,10)),n.height&&n.width)break}if(n.height&&n.width)return{height:n.height,width:n.width};throw new TypeError("Invalid PAM")}},kp={validate:t=>$r(t,0,2)in I0,calculate(t){const n=$r(t,0,2),i=I0[n],a=$r(t,3).split(/[\r\n]+/);return(M0[i]||M0.default)(a)}},Pp={validate:t=>$r(t,0,4)==="8BPS",calculate:t=>({height:bn(t,14),width:bn(t,18)})},F0=/<svg\s([^>"']|"[^"]*"|'[^']*')*>/,fu={height:/\sheight=(['"])([^%]+?)\1/,root:F0,viewbox:/\sviewBox=(['"])(.+?)\1/i,width:/\swidth=(['"])([^%]+?)\1/},qc=2.54,k0={in:96,cm:96/qc,em:16,ex:8,m:96/qc*100,mm:96/qc/10,pc:96/72/12,pt:96/72,px:1},Np=new RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(k0).join("|")})?$`);function lu(t){const n=Np.exec(t);if(!!n)return Math.round(Number(n[1])*(k0[n[2]]||1))}function Bp(t){const n=t.split(" ");return{height:lu(n[3]),width:lu(n[2])}}function Gp(t){const n=t.match(fu.width),i=t.match(fu.height),a=t.match(fu.viewbox);return{height:i&&lu(i[2]),viewbox:a&&Bp(a[2]),width:n&&lu(n[2])}}function Up(t){return{height:t.height,width:t.width}}function Yp(t,n){const i=n.width/n.height;return t.width?{height:Math.floor(t.width/i),width:t.width}:t.height?{height:t.height,width:Math.floor(t.height*i)}:{height:n.height,width:n.width}}const Hp={validate:t=>F0.test($r(t,0,1e3)),calculate(t){const n=$r(t).match(fu.root);if(n){const i=Gp(n[0]);if(i.width&&i.height)return Up(i);if(i.viewbox)return Yp(i,i.viewbox)}throw new TypeError("Invalid SVG")}},zp={validate(t){return ti(t,0)===0&&ti(t,4)===0},calculate(t){return{height:ti(t,14),width:ti(t,12)}}};function Wp(t,n){const i=Ui(t,32,4,n);return t.slice(i+2)}function Vp(t,n){const i=Ui(t,16,8,n);return(Ui(t,16,10,n)<<16)+i}function $p(t){if(t.length>24)return t.slice(12)}function Zp(t,n){const i={};let a=t;for(;a&&a.length;){const f=Ui(a,16,0,n),s=Ui(a,16,2,n),l=Ui(a,32,4,n);if(f===0)break;l===1&&(s===3||s===4)&&(i[f]=Vp(a,n)),a=$p(a)}return i}function Xp(t){const n=$r(t,0,2);if(n==="II")return"LE";if(n==="MM")return"BE"}const qp=["49492a00","4d4d002a"],Kp={validate:t=>qp.includes(Bs(t,0,4)),calculate(t){const n=Xp(t)==="BE",i=Wp(t,n),a=Zp(i,n),f=a[256],s=a[257];if(!f||!s)throw new TypeError("Invalid Tiff. Missing tags");return{height:s,width:f}}};function jp(t){return{height:1+A0(t,7),width:1+A0(t,4)}}function Qp(t){return{height:1+((t[4]&15)<<10|t[3]<<2|(t[2]&192)>>6),width:1+((t[2]&63)<<8|t[1])}}function Jp(t){return{height:S0(t,8)&16383,width:S0(t,6)&16383}}const em={validate(t){const n=$r(t,0,4)==="RIFF",i=$r(t,8,12)==="WEBP",a=$r(t,12,15)==="VP8";return n&&i&&a},calculate(t){const n=$r(t,12,16);if(t=t.slice(20,30),n==="VP8X"){const a=t[0],f=(a&192)===0,s=(a&1)===0;if(f&&s)return jp(t);throw new TypeError("Invalid WebP")}if(n==="VP8 "&&t[0]!==47)return Jp(t);const i=Bs(t,3,6);if(n==="VP8L"&&i!=="9d012a")return Qp(t);throw new TypeError("Invalid WebP")}},uu=new Map([["bmp",tp],["cur",op],["dds",sp],["gif",lp],["heif",cp],["icns",pp],["ico",D0],["j2c",mp],["jp2",gp],["jpg",Cp],["ktx",Op],["png",Fp],["pnm",kp],["psd",Pp],["svg",Hp],["tga",zp],["tiff",Kp],["webp",em]]),tm=Array.from(uu.keys()),rm=new Map([[56,"psd"],[66,"bmp"],[68,"dds"],[71,"gif"],[73,"tiff"],[77,"tiff"],[82,"webp"],[105,"icns"],[137,"png"],[255,"jpg"]]);function nm(t){const n=t[0],i=rm.get(n);return i&&uu.get(i).validate(t)?i:tm.find(a=>uu.get(a).validate(t))}const im={disabledTypes:[]};function P0(t){var i;const n=nm(t);if(typeof n<"u"){if(im.disabledTypes.indexOf(n)>-1)throw new TypeError("disabled file type: "+n);const a=uu.get(n).calculate(t);if(a!==void 0)return a.type=(i=a.type)!=null?i:n,a}throw new TypeError("unsupported file type: "+n)}var am=!1;const om=function(t,n){return(self.Image&&t instanceof self.Image||self.HTMLImageElement&&t instanceof self.HTMLImageElement)&&!t.complete?(n(null,new Error("\u4E0D\u652F\u6301\u7684\u683C\u5F0F")),!1):(di.imageHasData(t)?n&&n(t):sm(t,n),!0)};function sm(t,n){function i(l){try{var d=fm(l);t.exifdata=d||{};var v;n&&n(t)}catch(I){n(null,I)}}if(t.src)if(/^data\:/i.test(t.src)){var a=di.base64ToArrayBuffer(t.src);i(a)}else if(/^blob\:/i.test(t.src)){var f=new FileReader;f.onload=function(l){i(l.target.result)},di.objectURLToBlob(t.src,function(l){f.readAsArrayBuffer(l)})}else{var s=new XMLHttpRequest;s.onload=function(){if(this.status==200||this.status===0)i(s.response);else throw"Could not load image";s=null},s.open("GET",t.src,!0),s.responseType="arraybuffer",s.send(null)}else if(self.FileReader&&(t instanceof self.Blob||t instanceof self.File)){var f=new FileReader;f.onload=function(d){i(d.target.result)},f.readAsArrayBuffer(t)}}function fm(t){var n=new DataView(t);let i={};for(var a=2,f=t.byteLength,s;a<f&&n.getUint8(a)==255;){if(s=n.getUint8(a+1),s==225){i=lm(n,a+4,n.getUint16(a+2)-2);break}a+=2+n.getUint16(a+2)}let l=P0(new Uint8Array(t));return Object.assign(i,{PixelXDimension:l.width,PixelYDimension:l.height}),i}function JS(t){if("DOMParser"in self){var n=new DataView(t);if(n.getUint8(0)!=255||n.getUint8(1)!=216)return!1;for(var i=2,a=t.byteLength,f=new DOMParser;i<a-4;)if(di.getStringFromDB(n,i,4)=="http"){var s=i-1,l=n.getUint16(i-2)-1,d=di.getStringFromDB(n,s,l),v=d.indexOf("xmpmeta>")+8;d=d.substring(d.indexOf("<x:xmpmeta"),v);var I=d.indexOf("x:xmpmeta")+10;d=d.slice(0,I)+'xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" xmlns:ext="http://www.gettyimages.com/xsltExtension/1.0" xmlns:exif="http://ns.adobe.com/exif/1.0/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/" xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" '+d.slice(I);var B=f.parseFromString(d,"text/xml");return di.xml2Object(B)}else i++}}function lm(t,n){if(di.getStringFromDB(t,n,4)!="Exif")return!1;var i,a,f,s,l,d=n+6;if(t.getUint16(d)==18761)i=!1;else if(t.getUint16(d)==19789)i=!0;else return!1;if(t.getUint16(d+2,!i)!=42)return!1;var v=t.getUint32(d+4,!i);if(v<8)return!1;if(a=Kc(t,d,d+v,X_,i),a.ExifIFDPointer){s=Kc(t,d,d+a.ExifIFDPointer,q_,i);for(f in s){switch(f){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":s[f]=zf[f][s[f]];break;case"ExifVersion":case"FlashpixVersion":s[f]=String.fromCharCode(s[f][0],s[f][1],s[f][2],s[f][3]);break;case"ComponentsConfiguration":s[f]=zf.Components[s[f][0]]+zf.Components[s[f][1]]+zf.Components[s[f][2]]+zf.Components[s[f][3]];break}a[f]=s[f]}}if(a.GPSInfoIFDPointer){l=Kc(t,d,d+a.GPSInfoIFDPointer,K_,i);for(f in l){switch(f){case"GPSVersionID":l[f]=l[f][0]+"."+l[f][1]+"."+l[f][2]+"."+l[f][3];break}a[f]=l[f]}}return a}function Kc(t,n,i,a,f){var s=t.getUint16(i,!f),l={},d,v,I;for(I=0;I<s;I++)d=i+I*12+2,v=a[t.getUint16(d,!f)],l[v]=um(t,d,n,i,f);return l}function um(t,n,i,a,f){var s=t.getUint16(n+2,!f),l=t.getUint32(n+4,!f),d=t.getUint32(n+8,!f)+i,v,I,B,p,U,q;switch(s){case 1:case 7:if(l==1)return t.getUint8(n+8,!f);for(v=l>4?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint8(v+p);return I;case 2:return v=l>4?d:n+8,di.getStringFromDB(t,v,l-1);case 3:if(l==1)return t.getUint16(n+8,!f);for(v=l>2?d:n+8,I=[],p=0;p<l;p++)I[p]=t.getUint16(v+2*p,!f);return I;case 4:if(l==1)return t.getUint32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getUint32(d+4*p,!f);return I;case 5:if(l==1)return U=t.getUint32(d,!f),q=t.getUint32(d+4,!f),B=new Number(U/q),B.numerator=U,B.denominator=q,B;for(I=[],p=0;p<l;p++)U=t.getUint32(d+8*p,!f),q=t.getUint32(d+4+8*p,!f),I[p]=new Number(U/q),I[p].numerator=U,I[p].denominator=q;return I;case 9:if(l==1)return t.getInt32(n+8,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+4*p,!f);return I;case 10:if(l==1)return t.getInt32(d,!f)/t.getInt32(d+4,!f);for(I=[],p=0;p<l;p++)I[p]=t.getInt32(d+8*p,!f)/t.getInt32(d+4+8*p,!f);return I}}const cm=function(t){if(!di.imageHasData(t))return{};var n,i=t.exifdata,a={};for(n in i)i.hasOwnProperty(n)&&(a[n]=i[n]);return a},jc=t=>new Promise((n,i)=>{if(t.type==="image/jpeg"){let f=t.slice(0,524288);f.name=t.name,om(f,function(s,l){if(l){i(l);return}let d=cm(s),v=JSON.parse(JSON.stringify(d).replaceAll("\\u0000",""))||{};n(v)})}else{var a=new FileReader;a.onload=function(f){let s=new Uint8Array(f.target.result),l=P0(s);n({PixelXDimension:l.width,PixelYDimension:l.height})},a.readAsArrayBuffer(t)}});let cu;const hm=new Uint8Array(16);function dm(){if(!cu&&(cu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!cu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return cu(hm)}const Bn=[];for(let t=0;t<256;++t)Bn.push((t+256).toString(16).slice(1));function vm(t,n=0){return(Bn[t[n+0]]+Bn[t[n+1]]+Bn[t[n+2]]+Bn[t[n+3]]+"-"+Bn[t[n+4]]+Bn[t[n+5]]+"-"+Bn[t[n+6]]+Bn[t[n+7]]+"-"+Bn[t[n+8]]+Bn[t[n+9]]+"-"+Bn[t[n+10]]+Bn[t[n+11]]+Bn[t[n+12]]+Bn[t[n+13]]+Bn[t[n+14]]+Bn[t[n+15]]).toLowerCase()}const N0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _m(t,n,i){if(N0.randomUUID&&!n&&!t)return N0.randomUUID();t=t||{};const a=t.random||(t.rng||dm)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){i=i||0;for(let f=0;f<16;++f)n[i+f]=a[f];return n}return vm(a)}//! moment.js
|
|
4
4
|
//! version : 2.29.4
|
|
5
5
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
6
6
|
//! license : MIT
|
package/package.json
CHANGED
package/src/exif/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {imageSize} from '../image-size'
|
|
|
5
5
|
export const getPhotoTags = (file) => {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
7
|
if (file.type === 'image/jpeg') {
|
|
8
|
-
let sliceFile = file.slice(0,
|
|
8
|
+
let sliceFile = file.slice(0, 524288)
|
|
9
9
|
sliceFile.name = file.name
|
|
10
10
|
getData(sliceFile, function (img, err) {
|
|
11
11
|
if (err) {
|