@loaders.gl/images 3.1.0-alpha.4 → 3.1.0-alpha.5
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/dist/bundle.d.ts +1 -0
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/image-loader.js +6 -8
- package/dist/es5/image-loader.js.map +1 -1
- package/dist/es5/image-writer.js +1 -1
- package/dist/es5/image-writer.js.map +1 -1
- package/dist/es5/index.js +11 -11
- package/dist/es5/lib/category-api/binary-image-api.js +22 -22
- package/dist/es5/lib/category-api/binary-image-api.js.map +1 -1
- package/dist/es5/lib/category-api/image-format.js +7 -5
- package/dist/es5/lib/category-api/image-format.js.map +1 -1
- package/dist/es5/lib/category-api/image-type.js +7 -5
- package/dist/es5/lib/category-api/image-type.js.map +1 -1
- package/dist/es5/lib/category-api/parsed-image-api.js +4 -8
- package/dist/es5/lib/category-api/parsed-image-api.js.map +1 -1
- package/dist/es5/lib/encoders/encode-image.js +45 -97
- package/dist/es5/lib/encoders/encode-image.js.map +1 -1
- package/dist/es5/lib/parsers/parse-image.js +31 -66
- package/dist/es5/lib/parsers/parse-image.js.map +1 -1
- package/dist/es5/lib/parsers/parse-to-image-bitmap.js +26 -98
- package/dist/es5/lib/parsers/parse-to-image-bitmap.js.map +1 -1
- package/dist/es5/lib/parsers/parse-to-image.js +27 -93
- package/dist/es5/lib/parsers/parse-to-image.js.map +1 -1
- package/dist/es5/lib/parsers/parse-to-node-image.js +7 -35
- package/dist/es5/lib/parsers/parse-to-node-image.js.map +1 -1
- package/dist/es5/lib/parsers/svg-utils.js +5 -5
- package/dist/es5/lib/parsers/svg-utils.js.map +1 -1
- package/dist/es5/lib/texture-api/async-deep-map.js +27 -156
- package/dist/es5/lib/texture-api/async-deep-map.js.map +1 -1
- package/dist/es5/lib/texture-api/deep-load.js +6 -67
- package/dist/es5/lib/texture-api/deep-load.js.map +1 -1
- package/dist/es5/lib/texture-api/generate-url.js +7 -11
- package/dist/es5/lib/texture-api/generate-url.js.map +1 -1
- package/dist/es5/lib/texture-api/load-image.js +39 -143
- package/dist/es5/lib/texture-api/load-image.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/esm/lib/category-api/image-type.js +1 -1
- package/dist/esm/lib/category-api/image-type.js.map +1 -1
- package/dist/esm/lib/parsers/parse-to-image.js +1 -1
- package/dist/esm/lib/parsers/parse-to-image.js.map +1 -1
- package/dist/esm/lib/parsers/svg-utils.js +1 -1
- package/dist/esm/lib/parsers/svg-utils.js.map +1 -1
- package/dist/esm/lib/texture-api/generate-url.js +1 -1
- package/dist/esm/lib/texture-api/generate-url.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/image-loader.d.ts +25 -0
- package/dist/image-writer.d.ts +15 -0
- package/dist/index.d.ts +9 -0
- package/dist/lib/category-api/binary-image-api.d.ts +18 -0
- package/dist/lib/category-api/image-format.d.ts +4 -0
- package/dist/lib/category-api/image-type.d.ts +11 -0
- package/dist/lib/category-api/parsed-image-api.d.ts +9 -0
- package/dist/lib/encoders/encode-image.d.ts +11 -0
- package/dist/lib/parsers/parse-image.d.ts +4 -0
- package/dist/lib/parsers/parse-to-image-bitmap.d.ts +9 -0
- package/dist/lib/parsers/parse-to-image.d.ts +3 -0
- package/dist/lib/parsers/parse-to-node-image.d.ts +3 -0
- package/dist/lib/parsers/svg-utils.d.ts +3 -0
- package/dist/lib/texture-api/async-deep-map.d.ts +2 -0
- package/dist/lib/texture-api/deep-load.d.ts +2 -0
- package/dist/lib/texture-api/generate-url.d.ts +1 -0
- package/dist/lib/texture-api/load-image.d.ts +6 -0
- package/dist/lib/utils/version.d.ts +1 -0
- package/dist/types.d.ts +17 -0
- package/package.json +5 -4
|
@@ -25,7 +25,7 @@ export async function loadToImage(url, options) {
|
|
|
25
25
|
try {
|
|
26
26
|
image.onload = () => resolve(image);
|
|
27
27
|
|
|
28
|
-
image.onerror = err => reject(new Error(
|
|
28
|
+
image.onerror = err => reject(new Error("Could not load image ".concat(url, ": ").concat(err)));
|
|
29
29
|
} catch (error) {
|
|
30
30
|
reject(error);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parsers/parse-to-image.ts"],"names":["getBlobOrSVGDataUrl","parseToImage","arrayBuffer","options","url","blobOrDataUrl","URL","self","webkitURL","objectUrl","createObjectURL","loadToImage","revokeObjectURL","image","Image","src","decode","Promise","resolve","reject","onload","onerror","err","Error","error"],"mappings":"AACA,SAAQA,mBAAR,QAAkC,aAAlC;AAGA,eAAe,eAAeC,YAAf,CACbC,WADa,EAEbC,OAFa,EAGbC,GAHa,EAIc;AAK3B,QAAMC,aAAa,GAAGL,mBAAmB,CAACE,WAAD,EAAcE,GAAd,CAAzC;AACA,QAAME,GAAG,GAAGC,IAAI,CAACD,GAAL,IAAYC,IAAI,CAACC,SAA7B;AACA,QAAMC,SAAS,GAAG,OAAOJ,aAAP,KAAyB,QAAzB,IAAqCC,GAAG,CAACI,eAAJ,CAAoBL,aAApB,CAAvD;;AACA,MAAI;AACF,WAAO,MAAMM,WAAW,CAACF,SAAS,IAAIJ,aAAd,EAA6BF,OAA7B,CAAxB;AACD,GAFD,SAEU;AACR,QAAIM,SAAJ,EAAe;AACbH,MAAAA,GAAG,CAACM,eAAJ,CAAoBH,SAApB;AACD;AACF;AACF;AAED,OAAO,eAAeE,WAAf,CAA2BP,GAA3B,EAAgCD,OAAhC,EAAoE;AACzE,QAAMU,KAAK,GAAG,IAAIC,KAAJ,EAAd;AACAD,EAAAA,KAAK,CAACE,GAAN,GAAYX,GAAZ;;AASA,MAAID,OAAO,CAACU,KAAR,IAAiBV,OAAO,CAACU,KAAR,CAAcG,MAA/B,IAAyCH,KAAK,CAACG,MAAnD,EAA2D;AACzD,UAAMH,KAAK,CAACG,MAAN,EAAN;AACA,WAAOH,KAAP;AACD;;AAGD,SAAO,MAAM,IAAII,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC5C,QAAI;AACFN,MAAAA,KAAK,CAACO,MAAN,GAAe,MAAMF,OAAO,CAACL,KAAD,CAA5B;;AACAA,MAAAA,KAAK,CAACQ,OAAN,GAAiBC,GAAD,IAASH,MAAM,CAAC,IAAII,KAAJ,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parsers/parse-to-image.ts"],"names":["getBlobOrSVGDataUrl","parseToImage","arrayBuffer","options","url","blobOrDataUrl","URL","self","webkitURL","objectUrl","createObjectURL","loadToImage","revokeObjectURL","image","Image","src","decode","Promise","resolve","reject","onload","onerror","err","Error","error"],"mappings":"AACA,SAAQA,mBAAR,QAAkC,aAAlC;AAGA,eAAe,eAAeC,YAAf,CACbC,WADa,EAEbC,OAFa,EAGbC,GAHa,EAIc;AAK3B,QAAMC,aAAa,GAAGL,mBAAmB,CAACE,WAAD,EAAcE,GAAd,CAAzC;AACA,QAAME,GAAG,GAAGC,IAAI,CAACD,GAAL,IAAYC,IAAI,CAACC,SAA7B;AACA,QAAMC,SAAS,GAAG,OAAOJ,aAAP,KAAyB,QAAzB,IAAqCC,GAAG,CAACI,eAAJ,CAAoBL,aAApB,CAAvD;;AACA,MAAI;AACF,WAAO,MAAMM,WAAW,CAACF,SAAS,IAAIJ,aAAd,EAA6BF,OAA7B,CAAxB;AACD,GAFD,SAEU;AACR,QAAIM,SAAJ,EAAe;AACbH,MAAAA,GAAG,CAACM,eAAJ,CAAoBH,SAApB;AACD;AACF;AACF;AAED,OAAO,eAAeE,WAAf,CAA2BP,GAA3B,EAAgCD,OAAhC,EAAoE;AACzE,QAAMU,KAAK,GAAG,IAAIC,KAAJ,EAAd;AACAD,EAAAA,KAAK,CAACE,GAAN,GAAYX,GAAZ;;AASA,MAAID,OAAO,CAACU,KAAR,IAAiBV,OAAO,CAACU,KAAR,CAAcG,MAA/B,IAAyCH,KAAK,CAACG,MAAnD,EAA2D;AACzD,UAAMH,KAAK,CAACG,MAAN,EAAN;AACA,WAAOH,KAAP;AACD;;AAGD,SAAO,MAAM,IAAII,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC5C,QAAI;AACFN,MAAAA,KAAK,CAACO,MAAN,GAAe,MAAMF,OAAO,CAACL,KAAD,CAA5B;;AACAA,MAAAA,KAAK,CAACQ,OAAN,GAAiBC,GAAD,IAASH,MAAM,CAAC,IAAII,KAAJ,gCAAkCnB,GAAlC,eAA0CkB,GAA1C,EAAD,CAA/B;AACD,KAHD,CAGE,OAAOE,KAAP,EAAc;AACdL,MAAAA,MAAM,CAACK,KAAD,CAAN;AACD;AACF,GAPY,CAAb;AAQD","sourcesContent":["import type {ImageLoaderOptions} from '../../image-loader';\nimport {getBlobOrSVGDataUrl} from './svg-utils';\n\n// Parses html image from array buffer\nexport default async function parseToImage(\n arrayBuffer: ArrayBuffer,\n options: ImageLoaderOptions,\n url?: string\n): Promise<HTMLImageElement> {\n // Note: image parsing requires conversion to Blob (for createObjectURL).\n // Potentially inefficient for not using `response.blob()` (and for File / Blob inputs)...\n // But presumably not worth adding 'blob' flag to loader objects?\n\n const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);\n const URL = self.URL || self.webkitURL;\n const objectUrl = typeof blobOrDataUrl !== 'string' && URL.createObjectURL(blobOrDataUrl);\n try {\n return await loadToImage(objectUrl || blobOrDataUrl, options);\n } finally {\n if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n }\n}\n\nexport async function loadToImage(url, options): Promise<HTMLImageElement> {\n const image = new Image();\n image.src = url;\n\n // The `image.onload()` callback does not guarantee that the image has been decoded\n // so a main thread \"freeze\" can be incurred when using the image for the first time.\n // `Image.decode()` returns a promise that completes when image is decoded.\n\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode\n // Note: When calling `img.decode()`, we do not need to wait for `img.onload()`\n // Note: `HTMLImageElement.decode()` is not available in Edge and IE11\n if (options.image && options.image.decode && image.decode) {\n await image.decode();\n return image;\n }\n\n // Create a promise that tracks onload/onerror callbacks\n return await new Promise((resolve, reject) => {\n try {\n image.onload = () => resolve(image);\n image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));\n } catch (error) {\n reject(error);\n }\n });\n}\n"],"file":"parse-to-image.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parsers/svg-utils.ts"],"names":["SVG_DATA_URL_PATTERN","SVG_URL_PATTERN","isSVG","url","test","getBlobOrSVGDataUrl","arrayBuffer","textDecoder","TextDecoder","xmlText","decode","unescape","encodeURIComponent","error","Error","message","src","btoa","getBlob","Blob","Uint8Array"],"mappings":"AAGA,MAAMA,oBAAoB,GAAG,uBAA7B;AACA,MAAMC,eAAe,GAAG,mBAAxB;AAEA,OAAO,SAASC,KAAT,CAAeC,GAAf,EAAoB;AACzB,SAAOA,GAAG,KAAKH,oBAAoB,CAACI,IAArB,CAA0BD,GAA1B,KAAkCF,eAAe,CAACG,IAAhB,CAAqBD,GAArB,CAAvC,CAAV;AACD;AAED,OAAO,SAASE,mBAAT,CAA6BC,WAA7B,EAAuDH,GAAvD,EAAoF;AACzF,MAAID,KAAK,CAACC,GAAD,CAAT,EAAgB;AAEd,UAAMI,WAAW,GAAG,IAAIC,WAAJ,EAApB;AACA,QAAIC,OAAO,GAAGF,WAAW,CAACG,MAAZ,CAAmBJ,WAAnB,CAAd;;AAEA,QAAI;AACF,UAAI,OAAOK,QAAP,KAAoB,UAApB,IAAkC,OAAOC,kBAAP,KAA8B,UAApE,EAAgF;AAC9EH,QAAAA,OAAO,GAAGE,QAAQ,CAACC,kBAAkB,CAACH,OAAD,CAAnB,CAAlB;AACD;AACF,KAJD,CAIE,OAAOI,KAAP,EAAc;AACd,YAAM,IAAIC,KAAJ,CAAWD,KAAD,CAAiBE,OAA3B,CAAN;AACD;;AAED,UAAMC,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parsers/svg-utils.ts"],"names":["SVG_DATA_URL_PATTERN","SVG_URL_PATTERN","isSVG","url","test","getBlobOrSVGDataUrl","arrayBuffer","textDecoder","TextDecoder","xmlText","decode","unescape","encodeURIComponent","error","Error","message","src","btoa","getBlob","Blob","Uint8Array"],"mappings":"AAGA,MAAMA,oBAAoB,GAAG,uBAA7B;AACA,MAAMC,eAAe,GAAG,mBAAxB;AAEA,OAAO,SAASC,KAAT,CAAeC,GAAf,EAAoB;AACzB,SAAOA,GAAG,KAAKH,oBAAoB,CAACI,IAArB,CAA0BD,GAA1B,KAAkCF,eAAe,CAACG,IAAhB,CAAqBD,GAArB,CAAvC,CAAV;AACD;AAED,OAAO,SAASE,mBAAT,CAA6BC,WAA7B,EAAuDH,GAAvD,EAAoF;AACzF,MAAID,KAAK,CAACC,GAAD,CAAT,EAAgB;AAEd,UAAMI,WAAW,GAAG,IAAIC,WAAJ,EAApB;AACA,QAAIC,OAAO,GAAGF,WAAW,CAACG,MAAZ,CAAmBJ,WAAnB,CAAd;;AAEA,QAAI;AACF,UAAI,OAAOK,QAAP,KAAoB,UAApB,IAAkC,OAAOC,kBAAP,KAA8B,UAApE,EAAgF;AAC9EH,QAAAA,OAAO,GAAGE,QAAQ,CAACC,kBAAkB,CAACH,OAAD,CAAnB,CAAlB;AACD;AACF,KAJD,CAIE,OAAOI,KAAP,EAAc;AACd,YAAM,IAAIC,KAAJ,CAAWD,KAAD,CAAiBE,OAA3B,CAAN;AACD;;AAED,UAAMC,GAAG,uCAAgCC,IAAI,CAACR,OAAD,CAApC,CAAT;AACA,WAAOO,GAAP;AACD;;AACD,SAAOE,OAAO,CAACZ,WAAD,EAAcH,GAAd,CAAd;AACD;AAED,OAAO,SAASe,OAAT,CAAiBZ,WAAjB,EAA2CH,GAA3C,EAA+D;AACpE,MAAID,KAAK,CAACC,GAAD,CAAT,EAAgB;AAGd,UAAM,IAAIW,KAAJ,CAAU,8CAAV,CAAN;AACD;;AAED,SAAO,IAAIK,IAAJ,CAAS,CAAC,IAAIC,UAAJ,CAAed,WAAf,CAAD,CAAT,CAAP;AACD","sourcesContent":["// SVG parsing has limitations, e.g:\n// https://bugs.chromium.org/p/chromium/issues/detail?id=606319\n\nconst SVG_DATA_URL_PATTERN = /^data:image\\/svg\\+xml/;\nconst SVG_URL_PATTERN = /\\.svg((\\?|#).*)?$/;\n\nexport function isSVG(url) {\n return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));\n}\n\nexport function getBlobOrSVGDataUrl(arrayBuffer: ArrayBuffer, url?: string): Blob | string {\n if (isSVG(url)) {\n // Prepare a properly tagged data URL, and load using normal mechanism\n const textDecoder = new TextDecoder();\n let xmlText = textDecoder.decode(arrayBuffer);\n // TODO Escape in browser to support e.g. Chinese characters\n try {\n if (typeof unescape === 'function' && typeof encodeURIComponent === 'function') {\n xmlText = unescape(encodeURIComponent(xmlText));\n }\n } catch (error) {\n throw new Error((error as Error).message);\n }\n // base64 encoding is safer. utf-8 fails in some browsers\n const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;\n return src;\n }\n return getBlob(arrayBuffer, url);\n}\n\nexport function getBlob(arrayBuffer: ArrayBuffer, url?: string): Blob {\n if (isSVG(url)) {\n // https://bugs.chromium.org/p/chromium/issues/detail?id=606319\n // return new Blob([new Uint8Array(arrayBuffer)], {type: 'image/svg+xml'});\n throw new Error('SVG cannot be parsed directly to imagebitmap');\n }\n // TODO - how to determine mime type? Param? Sniff here?\n return new Blob([new Uint8Array(arrayBuffer)]); // MIME type not needed?\n}\n"],"file":"svg-utils.js"}
|
|
@@ -14,7 +14,7 @@ export function generateUrl(getUrl, options, urlOptions) {
|
|
|
14
14
|
} = options;
|
|
15
15
|
|
|
16
16
|
if (baseUrl) {
|
|
17
|
-
url = baseUrl[baseUrl.length - 1] === '/' ?
|
|
17
|
+
url = baseUrl[baseUrl.length - 1] === '/' ? "".concat(baseUrl).concat(url) : "".concat(baseUrl, "/").concat(url);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return resolvePath(url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/texture-api/generate-url.ts"],"names":["resolvePath","assert","generateUrl","getUrl","options","urlOptions","url","baseUrl","length"],"mappings":"AAAA,SAAQA,WAAR,EAAqBC,MAArB,QAAkC,0BAAlC;AAGA,OAAO,SAASC,WAAT,CAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,UAAtC,EAAkD;AAEvD,MAAIC,GAAG,GAAGH,MAAV;;AACA,MAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC;AAChCG,IAAAA,GAAG,GAAGH,MAAM,CAAC,EAAC,GAAGC,OAAJ;AAAa,SAAGC;AAAhB,KAAD,CAAZ;AACD;;AACDJ,EAAAA,MAAM,CAAC,OAAOK,GAAP,KAAe,QAAhB,CAAN;AAGA,QAAM;AAACC,IAAAA;AAAD,MAAYH,OAAlB;;AACA,MAAIG,OAAJ,EAAa;AACXD,IAAAA,GAAG,GAAGC,OAAO,CAACA,OAAO,CAACC,MAAR,GAAiB,CAAlB,CAAP,KAAgC,GAAhC,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/texture-api/generate-url.ts"],"names":["resolvePath","assert","generateUrl","getUrl","options","urlOptions","url","baseUrl","length"],"mappings":"AAAA,SAAQA,WAAR,EAAqBC,MAArB,QAAkC,0BAAlC;AAGA,OAAO,SAASC,WAAT,CAAqBC,MAArB,EAA6BC,OAA7B,EAAsCC,UAAtC,EAAkD;AAEvD,MAAIC,GAAG,GAAGH,MAAV;;AACA,MAAI,OAAOA,MAAP,KAAkB,UAAtB,EAAkC;AAChCG,IAAAA,GAAG,GAAGH,MAAM,CAAC,EAAC,GAAGC,OAAJ;AAAa,SAAGC;AAAhB,KAAD,CAAZ;AACD;;AACDJ,EAAAA,MAAM,CAAC,OAAOK,GAAP,KAAe,QAAhB,CAAN;AAGA,QAAM;AAACC,IAAAA;AAAD,MAAYH,OAAlB;;AACA,MAAIG,OAAJ,EAAa;AACXD,IAAAA,GAAG,GAAGC,OAAO,CAACA,OAAO,CAACC,MAAR,GAAiB,CAAlB,CAAP,KAAgC,GAAhC,aAAyCD,OAAzC,SAAmDD,GAAnD,cAA8DC,OAA9D,cAAyED,GAAzE,CAAN;AACD;;AAED,SAAON,WAAW,CAACM,GAAD,CAAlB;AACD","sourcesContent":["import {resolvePath, assert} from '@loaders.gl/loader-utils';\n\n// Generate a url by calling getUrl with mix of options, applying options.baseUrl\nexport function generateUrl(getUrl, options, urlOptions) {\n // Get url\n let url = getUrl;\n if (typeof getUrl === 'function') {\n url = getUrl({...options, ...urlOptions});\n }\n assert(typeof url === 'string');\n\n // Apply options.baseUrl\n const {baseUrl} = options;\n if (baseUrl) {\n url = baseUrl[baseUrl.length - 1] === '/' ? `${baseUrl}${url}` : `${baseUrl}/${url}`;\n }\n\n return resolvePath(url);\n}\n"],"file":"generate-url.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = typeof "3.1.0-alpha.
|
|
1
|
+
export const VERSION = typeof "3.1.0-alpha.5" !== 'undefined' ? "3.1.0-alpha.5" : 'latest';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
import parseImage from './lib/parsers/parse-image';
|
|
3
|
+
export declare type ImageLoaderOptions = LoaderOptions & {
|
|
4
|
+
image?: {
|
|
5
|
+
type?: 'auto' | 'data' | 'imagebitmap' | 'image';
|
|
6
|
+
decode?: boolean;
|
|
7
|
+
};
|
|
8
|
+
imagebitmap?: ImageBitmapOptions;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Loads a platform-specific image type
|
|
12
|
+
* Note: This type can be used as input data to WebGL texture creation
|
|
13
|
+
*/
|
|
14
|
+
export declare const ImageLoader: {
|
|
15
|
+
id: string;
|
|
16
|
+
module: string;
|
|
17
|
+
name: string;
|
|
18
|
+
version: any;
|
|
19
|
+
mimeTypes: string[];
|
|
20
|
+
extensions: string[];
|
|
21
|
+
parse: typeof parseImage;
|
|
22
|
+
tests: ((arrayBuffer: any) => boolean)[];
|
|
23
|
+
options: ImageLoaderOptions;
|
|
24
|
+
};
|
|
25
|
+
export declare const _typecheckImageLoader: LoaderWithParser;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { encodeImage } from './lib/encoders/encode-image';
|
|
2
|
+
export declare const ImageWriter: {
|
|
3
|
+
name: string;
|
|
4
|
+
id: string;
|
|
5
|
+
module: string;
|
|
6
|
+
version: any;
|
|
7
|
+
extensions: string[];
|
|
8
|
+
options: {
|
|
9
|
+
image: {
|
|
10
|
+
mimeType: string;
|
|
11
|
+
jpegQuality: null;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
encode: typeof encodeImage;
|
|
15
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { ImageDataType, ImageType, ImageTypeEnum } from './types';
|
|
2
|
+
export type { ImageLoaderOptions } from './image-loader';
|
|
3
|
+
export { ImageLoader } from './image-loader';
|
|
4
|
+
export { ImageWriter } from './image-writer';
|
|
5
|
+
export { getBinaryImageMetadata } from './lib/category-api/binary-image-api';
|
|
6
|
+
export { isImageTypeSupported, getDefaultImageType } from './lib/category-api/image-type';
|
|
7
|
+
export { isImage, getImageType, getImageSize, getImageData } from './lib/category-api/parsed-image-api';
|
|
8
|
+
export { _isImageFormatSupported } from './lib/category-api/image-format';
|
|
9
|
+
export { loadImage } from './lib/texture-api/load-image';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** MIME type, width and height extracted from binary compressed image data */
|
|
2
|
+
export declare type BinaryImageMetadata = {
|
|
3
|
+
mimeType: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Extracts `{mimeType, width and height}` from a memory buffer containing a known image format
|
|
9
|
+
* Currently supports `image/png`, `image/jpeg`, `image/bmp` and `image/gif`.
|
|
10
|
+
* @param binaryData image file memory to parse
|
|
11
|
+
* @returns metadata or null if memory is not a valid image file format layout.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBinaryImageMetadata(binaryData: DataView | ArrayBuffer): BinaryImageMetadata | null;
|
|
14
|
+
export declare function getBmpMetadata(binaryData: any): {
|
|
15
|
+
mimeType: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
} | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImageTypeEnum } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a loaders.gl image type is supported
|
|
4
|
+
* @param type image type string
|
|
5
|
+
*/
|
|
6
|
+
export declare function isImageTypeSupported(type: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the "most performant" supported image type on this platform
|
|
9
|
+
* @returns image type string
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDefaultImageType(): ImageTypeEnum;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImageType, ImageTypeEnum, ImageDataType } from '../../types';
|
|
2
|
+
export declare function isImage(image: ImageType): boolean;
|
|
3
|
+
export declare function deleteImage(image: ImageType): void;
|
|
4
|
+
export declare function getImageType(image: ImageType): ImageTypeEnum;
|
|
5
|
+
export declare function getImageSize(image: ImageType): {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function getImageData(image: ImageType): ImageDataType | ImageData;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns data bytes representing a compressed image in PNG or JPG format,
|
|
3
|
+
* This data can be saved using file system (f) methods or used in a request.
|
|
4
|
+
* @param image - ImageBitmap Image or Canvas
|
|
5
|
+
* @param options
|
|
6
|
+
* param opt.type='png' - png, jpg or image/png, image/jpg are valid
|
|
7
|
+
* param mimeType= - Whether to include a data URI header
|
|
8
|
+
*/
|
|
9
|
+
export declare function encodeImage(image: any, options?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}): Promise<ArrayBuffer>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { ImageType } from '../../types';
|
|
3
|
+
import type { ImageLoaderOptions } from '../../image-loader';
|
|
4
|
+
export default function parseImage(arrayBuffer: ArrayBuffer, options?: ImageLoaderOptions, context?: LoaderContext): Promise<ImageType>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImageLoaderOptions } from '../../image-loader';
|
|
2
|
+
/**
|
|
3
|
+
* Asynchronously parses an array buffer into an ImageBitmap - this contains the decoded data
|
|
4
|
+
* ImageBitmaps are supported on worker threads, but not supported on Edge, IE11 and Safari
|
|
5
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap#Browser_compatibility
|
|
6
|
+
*
|
|
7
|
+
* TODO - createImageBitmap supports source rect (5 param overload), pass through?
|
|
8
|
+
*/
|
|
9
|
+
export default function parseToImageBitmap(arrayBuffer: ArrayBuffer, options: ImageLoaderOptions, url?: string): Promise<ImageBitmap>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ImageLoaderOptions } from '../../image-loader';
|
|
2
|
+
export default function parseToImage(arrayBuffer: ArrayBuffer, options: ImageLoaderOptions, url?: string): Promise<HTMLImageElement>;
|
|
3
|
+
export declare function loadToImage(url: any, options: any): Promise<HTMLImageElement>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateUrl(getUrl: any, options: any, urlOptions: any): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function loadImage(getUrl: any, options?: {}): Promise<any>;
|
|
2
|
+
export declare function getImageUrls(getUrl: any, options: any, urlOptions?: {}): Promise<string | string[]>;
|
|
3
|
+
export declare function getMipLevels({ width, height }: {
|
|
4
|
+
width: any;
|
|
5
|
+
height: any;
|
|
6
|
+
}): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION: any;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data images
|
|
3
|
+
*/
|
|
4
|
+
export declare type ImageDataType = {
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
compressed?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Supported Image Types
|
|
12
|
+
*/
|
|
13
|
+
export declare type ImageType = ImageBitmap | typeof Image | ImageDataType;
|
|
14
|
+
/**
|
|
15
|
+
* Image type string used to control or determine the type of images returned from ImageLoader
|
|
16
|
+
*/
|
|
17
|
+
export declare type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/images",
|
|
3
|
-
"version": "3.1.0-alpha.
|
|
3
|
+
"version": "3.1.0-alpha.5",
|
|
4
4
|
"description": "Framework-independent loaders and writers for images (PNG, JPG, ...)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"point cloud",
|
|
19
19
|
"PLY"
|
|
20
20
|
],
|
|
21
|
-
"types": "
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
22
|
"main": "dist/es5/index.js",
|
|
23
23
|
"module": "dist/esm/index.js",
|
|
24
24
|
"sideEffects": false,
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"pre-build": "npm run build-bundle",
|
|
32
|
+
"post-build": "tsc",
|
|
32
33
|
"build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js",
|
|
33
34
|
"build-worker": "webpack --entry ./src/image-worker.js --output ./dist/image-worker.js --config ../../scripts/webpack/worker.js"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@loaders.gl/loader-utils": "3.1.0-alpha.
|
|
37
|
+
"@loaders.gl/loader-utils": "3.1.0-alpha.5"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
|
|
39
40
|
}
|