1 line
22 KiB
JavaScript
1 line
22 KiB
JavaScript
|
|
(()=>{var t={457:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.detector=void 0;const r=n(229);const i=Object.keys(r.typeHandlers);const s={56:"psd",66:"bmp",68:"dds",71:"gif",73:"tiff",77:"tiff",82:"webp",105:"icns",137:"png",255:"jpg"};function detector(t){const e=t[0];if(e in s){const n=s[e];if(n&&r.typeHandlers[n].validate(t)){return n}}const finder=e=>r.typeHandlers[e].validate(t);return i.find(finder)}e.detector=detector},833:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.types=e.setConcurrency=e.disableTypes=e.disableFS=e.imageSize=void 0;const r=n(147);const i=n(17);const s=n(927);const o=n(229);const c=n(457);const a=512*1024;const u=new s.default({concurrency:100,autostart:true});const d={disabledFS:false,disabledTypes:[]};function lookup(t,e){const n=(0,c.detector)(t);if(typeof n!=="undefined"){if(d.disabledTypes.indexOf(n)>-1){throw new TypeError("disabled file type: "+n)}if(n in o.typeHandlers){const r=o.typeHandlers[n].calculate(t,e);if(r!==undefined){r.type=r.type??n;return r}}}throw new TypeError("unsupported file type: "+n+" (file: "+e+")")}async function readFileAsync(t){const e=await r.promises.open(t,"r");try{const{size:t}=await e.stat();if(t<=0){throw new Error("Empty file")}const n=Math.min(t,a);const r=new Uint8Array(n);await e.read(r,0,n,0);return r}finally{await e.close()}}function readFileSync(t){const e=r.openSync(t,"r");try{const{size:t}=r.fstatSync(e);if(t<=0){throw new Error("Empty file")}const n=Math.min(t,a);const i=new Uint8Array(n);r.readSync(e,i,0,n,0);return i}finally{r.closeSync(e)}}t.exports=e=imageSize;e["default"]=imageSize;function imageSize(t,e){if(t instanceof Uint8Array){return lookup(t)}if(typeof t!=="string"||d.disabledFS){throw new TypeError("invalid invocation. input should be a Uint8Array")}const n=i.resolve(t);if(typeof e==="function"){u.push((()=>readFileAsync(n).then((t=>process.nextTick(e,null,lookup(t,n)))).catch(e)))}else{const t=readFileSync(n);return lookup(t,n)}}e.imageSize=imageSize;const disableFS=t=>{d.disabledFS=t};e.disableFS=disableFS;const disableTypes=t=>{d.disabledTypes=t};e.disableTypes=disableTypes;const setConcurrency=t=>{u.concurrency=t};e.setConcurrency=setConcurrency;e.types=Object.keys(o.typeHandlers)},436:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.BMP=void 0;const r=n(779);e.BMP={validate:t=>(0,r.toUTF8String)(t,0,2)==="BM",calculate:t=>({height:Math.abs((0,r.readInt32LE)(t,22)),width:(0,r.readUInt32LE)(t,18)})}},67:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.CUR=void 0;const r=n(845);const i=n(779);const s=2;e.CUR={validate(t){const e=(0,i.readUInt16LE)(t,0);const n=(0,i.readUInt16LE)(t,4);if(e!==0||n===0)return false;const r=(0,i.readUInt16LE)(t,2);return r===s},calculate:t=>r.ICO.calculate(t)}},400:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.DDS=void 0;const r=n(779);e.DDS={validate:t=>(0,r.readUInt32LE)(t,0)===542327876,calculate:t=>({height:(0,r.readUInt32LE)(t,12),width:(0,r.readUInt32LE)(t,16)})}},197:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.GIF=void 0;const r=n(779);const i=/^GIF8[79]a/;e.GIF={validate:t=>i.test((0,r.toUTF8String)(t,0,6)),calculate:t=>({height:(0,r.readUInt16LE)(t,8),width:(0,r.readUInt16LE)(t,6)})}},974:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:true});e.HEIF=void 0;const r=n(779);const i={avif:"avif",mif1:"heif",msf1:"heif",heic:"heic",heix:"heic",hevc:"heic",hevx:"heic"};e.HEIF={validate(t){const e=(0,r.toUTF8String)(t,4,8);if(e!=="ftyp")return false;const n=(0,r.findBox)(t,"ftyp",0);if(!n)return false;const s=(0,r.toUTF8String)(t,n.offset+8,n.offset+12);return s in i},calculate(t){const e=(0,r.findBox)(t,"meta",0);const n=e&&(0,r.findBox)(t,"iprp",e.offset+12);const i=n&&(0,r.findBox)(t,"ipco",n.offset+8);const s=i&&(0,r.findBox)(t,"ispe",i.offset+8);if(s){return{height:(0,r.readUInt32BE)(t,s.offset+16),width:(0,r.readUInt32BE)(t,s.offset+12),type:(0,r.toUTF8String)(t,8,12)}}throw new TypeError("Invalid HEIF
|