UNPKG

image-resolution-checker

Version:

A Vue 3 plugin for checking image resolutions with per - page settings

37 lines (36 loc) 993 B
const d = (e, a, i) => new Promise((t, o) => { const r = new FileReader(); r.onload = (l) => { var s; const n = new Image(); n.onload = () => { const c = n.width >= a, h = n.height >= i; t(c && h); }, n.onerror = () => { o(new Error("Failed to load the image.")); }, n.src = (s = l.target) == null ? void 0 : s.result; }, r.onerror = () => { o(new Error("Failed to read the image file.")); }, r.readAsDataURL(e); }), g = async (e, a, i) => { if (!e) return []; const t = []; for (let o = 0; o < e.length; o++) try { const r = await d(e[o], a, i); t.push({ file: e[o], isValid: r }); } catch (r) { console.error(`Error checking resolution of file ${e[o].name}:`, r), t.push({ file: e[o], isValid: !1 }); } return t; }, u = { install: (e) => { e.config.globalProperties.$checkImageResolutions = g; } }; export { g as checkImageResolutions, d as checkSingleImageResolution, u as default };