@loaders.gl/images
Advanced tools
Comparing version 1.1.0-beta.1 to 1.1.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"a",function(){return i});"object"!=typeof e||"[object process]"!==String(e)||e.browser;const o={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==r&&r},i=o.global||o.self||o.window}).call(this,n(3),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const r=n(4),o="undefined"==typeof window?t:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,r)}).call(this,n(1))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var c,f=[],s=!1,l=-1;function d(){s&&c&&(s=!1,c.length?f=c.concat(f):l=-1,f.length&&g())}function g(){if(!s){var e=u(d);s=!0;for(var t=f.length;t;){for(c=f,f=[];++l<t;)c&&c[l].run();l=-1,t=f.length}c=null,s=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new m(e,t)),1!==f.length||s||u(g)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.r(t);var r=n(0);const o=!1,i=!0,a=new Map([["image/png",{test:function(e){return e.byteLength>=24&&2303741511===e.getUint32(0,o)},getSize:function(e){return{width:e.getUint32(16,o),height:e.getUint32(20,o)}}}],["image/jpeg",{test:function(e){return e.byteLength>=2&&65496===e.getUint16(0,o)},getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,o))return null;const{tableMarkers:t,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const i=e.getUint16(r,o);if(n.has(i))return{height:e.getUint16(r+5,o),width:e.getUint16(r+7,o)};if(!t.has(i))return null;r+=2,r+=e.getUint16(r,o)}return null}}],["image/gif",{test:function(e){return e.byteLength>=10&&1195984440===e.getUint32(0,o)},getSize:function(e){return{width:e.getUint16(6,i),height:e.getUint16(8,i)}}}],["image/bmp",{test:function(e){return e.byteLength>=2&&16973===e.getUint16(0,o)},getSize:function(e){return{width:e.getUint32(18,i),height:e.getUint32(22,i)}}}]]);const u=`Invalid MIME type. Supported MIME types are: ${Array.from(a.keys()).join(", ")}`;function c(e,t){if(t){const{test:n}=d(t);return n(g(e))}return Boolean(f(e))}function f(e){const t=g(e);for(const[e,{test:n}]of a.entries())if(n(t))return e;return null}function s(e,t=null){t=t||f(e);const{getSize:n}=d(t),r=n(g(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}function l(e,t=null){const n=s(e,t=t||f(e));return n.mimeType=t,n}function d(e){const t=a.get(e);if(!t)throw new Error(u);return t}function g(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}const m=r.a._parseImageNode||"undefined"!=typeof ImageBitmap;function p(e,t){if(r.a._parseImageNode){const{mimeType:n}=l(e);return r.a._parseImageNode(e,n,t)}return h(e)}async function w(e,t){if("undefined"==typeof Image){const n=await fetch(e,t);return p(await n.arrayBuffer())}return await y(e,t)}function h(e){if("undefined"==typeof createImageBitmap)throw new Error("parseImage");const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)}async function y(e,t){let n;if(/\.svg((\?|#).*)?$/.test(e)){const r=await fetch(e,t),o=await r.text();n=`data:image/svg+xml;base64,${btoa(o)}`}else n=await e;return await new Promise((r,o)=>{try{const i=new Image;i.onload=(()=>r(i)),i.onerror=(t=>o(new Error(`Could not load image ${e}: ${t}`))),i.crossOrigin=t&&t.crossOrigin||"anonymous",i.src=n}catch(e){o(e)}})}var b={name:"Images",extension:[],parse:m&&p,loadAndParse:!m&&w};const v={parse:h},I={loadAndParse:y};var T={name:"Images",extensions:["jpeg"],encode:function(e,t){if(r.a._encodeImageNode)return r.a._encodeImageNode(e,t);if(e instanceof HTMLCanvasElement)return e.toDataURL(t);!function(e,t){if(!e)throw new Error(t||"@loaders.gl/images assertion failed.")}(e instanceof Image,"getImageData accepts image or canvas");const n=document.createElement("canvas");n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0);const o=n.toDataURL(t||"png").replace(/^data:image\/(png|jpg);base64,/,"");return Promise.resolve(o)},DEFAULT_OPTIONS:{type:"png"}};function L(e,{mimeType:t="image/jpeg"}){const n=new Blob([e],{type:t}),r=(window.URL||window.webkitURL).createObjectURL(n);return new Promise((e,t)=>{const n=new Image;return n.onload=(()=>e(n)),n.onerror=t,n.src=r,n})}n.d(t,"ImageLoader",function(){return b}),n.d(t,"HTMLImageLoader",function(){return I}),n.d(t,"ImageBitmapLoader",function(){return v}),n.d(t,"ImageWriter",function(){return T}),n.d(t,"loadImage",function(){return w}),n.d(t,"isImage",function(){return c}),n.d(t,"getImageMetadata",function(){return l}),n.d(t,"getImageMIMEType",function(){return f}),n.d(t,"getImageSize",function(){return s}),n.d(t,"decodeImage",function(){return L})}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"a",function(){return i});"object"!=typeof e||"[object process]"!==String(e)||e.browser;const o={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==r&&r},i=o.global||o.self||o.window}).call(this,n(3),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const r=n(4),o="undefined"==typeof window?t:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,r)}).call(this,n(1))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var c,f=[],s=!1,l=-1;function d(){s&&c&&(s=!1,c.length?f=c.concat(f):l=-1,f.length&&g())}function g(){if(!s){var e=u(d);s=!0;for(var t=f.length;t;){for(c=f,f=[];++l<t;)c&&c[l].run();l=-1,t=f.length}c=null,s=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new m(e,t)),1!==f.length||s||u(g)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.r(t);var r=n(0);const o=!1,i=!0,a=new Map([["image/png",{test:function(e){return e.byteLength>=24&&2303741511===e.getUint32(0,o)},getSize:function(e){return{width:e.getUint32(16,o),height:e.getUint32(20,o)}}}],["image/jpeg",{test:function(e){return e.byteLength>=2&&65496===e.getUint16(0,o)},getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,o))return null;const{tableMarkers:t,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const i=e.getUint16(r,o);if(n.has(i))return{height:e.getUint16(r+5,o),width:e.getUint16(r+7,o)};if(!t.has(i))return null;r+=2,r+=e.getUint16(r,o)}return null}}],["image/gif",{test:function(e){return e.byteLength>=10&&1195984440===e.getUint32(0,o)},getSize:function(e){return{width:e.getUint16(6,i),height:e.getUint16(8,i)}}}],["image/bmp",{test:function(e){return e.byteLength>=2&&16973===e.getUint16(0,o)},getSize:function(e){return{width:e.getUint32(18,i),height:e.getUint32(22,i)}}}]]);const u=`Invalid MIME type. Supported MIME types are: ${Array.from(a.keys()).join(", ")}`;function c(e,t){if(t){const{test:n}=d(t);return n(g(e))}return Boolean(f(e))}function f(e){const t=g(e);for(const[e,{test:n}]of a.entries())if(n(t))return e;return null}function s(e,t=null){t=t||f(e);const{getSize:n}=d(t),r=n(g(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}function l(e,t=null){const n=s(e,t=t||f(e));return n.mimeType=t,n}function d(e){const t=a.get(e);if(!t)throw new Error(u);return t}function g(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}const m=r.a._parseImageNode||"undefined"!=typeof ImageBitmap;function p(e,t){if(r.a._parseImageNode){const{mimeType:n}=l(e);return r.a._parseImageNode(e,n,t)}return h(e)}async function w(e,t){if("undefined"==typeof Image){const n=await fetch(e,t);return p(await n.arrayBuffer())}return await y(e,t)}function h(e){if("undefined"==typeof createImageBitmap)throw new Error("parseImage");const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)}async function y(e,t){let n;if(/\.svg((\?|#).*)?$/.test(e)){const r=await fetch(e,t),o=await r.text();n=`data:image/svg+xml;base64,${btoa(o)}`}else n=await e;return await new Promise((r,o)=>{try{const i=new Image;i.onload=()=>r(i),i.onerror=t=>o(new Error(`Could not load image ${e}: ${t}`)),i.crossOrigin=t&&t.crossOrigin||"anonymous",i.src=n}catch(e){o(e)}})}var b={name:"Images",extension:[],parse:m&&p,loadAndParse:!m&&w};const v={parse:h},I={loadAndParse:y};var T={name:"Images",extensions:["jpeg"],encode:function(e,t){if(r.a._encodeImageNode)return r.a._encodeImageNode(e,t);if(e instanceof HTMLCanvasElement)return e.toDataURL(t);!function(e,t){if(!e)throw new Error(t||"@loaders.gl/images assertion failed.")}(e instanceof Image,"getImageData accepts image or canvas");const n=document.createElement("canvas");n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0);const o=n.toDataURL(t||"png").replace(/^data:image\/(png|jpg);base64,/,"");return Promise.resolve(o)},DEFAULT_OPTIONS:{type:"png"}};function L(e,{mimeType:t="image/jpeg"}){const n=new Blob([e],{type:t}),r=(window.URL||window.webkitURL).createObjectURL(n);return new Promise((e,t)=>{const n=new Image;return n.onload=()=>e(n),n.onerror=t,n.src=r,n})}n.d(t,"ImageLoader",function(){return b}),n.d(t,"HTMLImageLoader",function(){return I}),n.d(t,"ImageBitmapLoader",function(){return v}),n.d(t,"ImageWriter",function(){return T}),n.d(t,"loadImage",function(){return w}),n.d(t,"isImage",function(){return c}),n.d(t,"getImageMetadata",function(){return l}),n.d(t,"getImageMIMEType",function(){return f}),n.d(t,"getImageSize",function(){return s}),n.d(t,"decodeImage",function(){return L})}])}); |
@@ -1,2 +0,1 @@ | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import { mimeTypeMap } from './image-parsers'; | ||
@@ -6,5 +5,5 @@ const ERR_INVALID_MIME_TYPE = "Invalid MIME type. Supported MIME types are: ".concat(Array.from(mimeTypeMap.keys()).join(', ')); | ||
if (mimeType) { | ||
const _getImageTypeHandlers = getImageTypeHandlers(mimeType), | ||
test = _getImageTypeHandlers.test; | ||
const { | ||
test | ||
} = getImageTypeHandlers(mimeType); | ||
const dataView = toDataView(arrayBuffer); | ||
@@ -19,8 +18,5 @@ return test(dataView); | ||
for (const _ref of mimeTypeMap.entries()) { | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
const mimeType = _ref2[0]; | ||
const test = _ref2[1].test; | ||
for (const [mimeType, { | ||
test | ||
}] of mimeTypeMap.entries()) { | ||
if (test(dataView)) { | ||
@@ -36,6 +32,5 @@ return mimeType; | ||
mimeType = mimeType || getImageMIMEType(arrayBuffer); | ||
const _getImageTypeHandlers2 = getImageTypeHandlers(mimeType), | ||
getSize = _getImageTypeHandlers2.getSize; | ||
const { | ||
getSize | ||
} = getImageTypeHandlers(mimeType); | ||
const dataView = toDataView(arrayBuffer); | ||
@@ -42,0 +37,0 @@ const size = getSize(dataView); |
@@ -59,6 +59,6 @@ const BIG_ENDIAN = false; | ||
const _getJpegMarkers = getJpegMarkers(), | ||
tableMarkers = _getJpegMarkers.tableMarkers, | ||
sofMarkers = _getJpegMarkers.sofMarkers; | ||
const { | ||
tableMarkers, | ||
sofMarkers | ||
} = getJpegMarkers(); | ||
let i = 2; | ||
@@ -65,0 +65,0 @@ |
export function decodeImage(arrayBufferOrView, _ref) { | ||
let _ref$mimeType = _ref.mimeType, | ||
mimeType = _ref$mimeType === void 0 ? 'image/jpeg' : _ref$mimeType; | ||
let { | ||
mimeType = 'image/jpeg' | ||
} = _ref; | ||
const blob = new Blob([arrayBufferOrView], { | ||
@@ -5,0 +6,0 @@ type: mimeType |
@@ -7,5 +7,5 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
if (global._parseImageNode) { | ||
const _getImageMetadata = getImageMetadata(arrayBuffer), | ||
mimeType = _getImageMetadata.mimeType; | ||
const { | ||
mimeType | ||
} = getImageMetadata(arrayBuffer); | ||
return global._parseImageNode(arrayBuffer, mimeType, options); | ||
@@ -12,0 +12,0 @@ } |
{ | ||
"name": "@loaders.gl/images", | ||
"version": "1.1.0-beta.1", | ||
"version": "1.1.0", | ||
"description": "Framework-independent loaders and writers for images (PNG, JPG, ...)", | ||
@@ -33,3 +33,4 @@ "license": "MIT", | ||
"build-bundle": "webpack --display=minimal --config ../../scripts/bundle.config.js" | ||
} | ||
}, | ||
"gitHead": "3e703baf6d39bbefce19a509709f5dc80a1cc428" | ||
} |
# @loaders.gl/images | ||
[loaders.gl](https://uber-web.github.io/loaders.gl/#/docs) is a collection of framework independent 3D and geospatial parsers and encoders. | ||
[loaders.gl](https://loaders.gl/docs) is a collection of framework independent 3D and geospatial parsers and encoders. | ||
@@ -5,0 +5,0 @@ This module contains loader and writers for images that follow loaders.gl conventions and work under both node and browser. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
182047
82
2299
1
50
1