diff --git a/.gitignore b/.gitignore index a36d949..4a03588 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules package.json package-lock.json +libopenjpeg* \ No newline at end of file diff --git a/demo/serviceWorker/index.js b/demo/serviceWorker/index.js index 934ba5f..f6c242e 100644 --- a/demo/serviceWorker/index.js +++ b/demo/serviceWorker/index.js @@ -282,7 +282,6 @@ imgBox.addServiceWorker = async () => { navigator.serviceWorker.register(`../../imagebox3.js?tileServerPathSuffix=${tileServerPathSuffix}`) .catch((error) => { console.log('Service worker registration failed', error) - reject(error) }) await navigator.serviceWorker.ready } diff --git a/imagebox3.js b/imagebox3.js index e0661cb..95f06bc 100644 --- a/imagebox3.js +++ b/imagebox3.js @@ -218,7 +218,7 @@ var imagebox3 = (() => { try { const headers = cache ? { headers: {'Cache-Control': "no-cache, no-store"}} : {} - tiff[imageID].pyramid = tiff[imageID].pyramid || ( await GeoTIFF.fromUrl(imageID, headers) ) + tiff[imageID].pyramid = tiff[imageID].pyramid || ( imageID instanceof File ? await GeoTIFF.fromBlob(imageID) : await GeoTIFF.fromUrl(imageID, headers) ) const imageCount = await tiff[imageID].pyramid.getImageCount() if (tiff[imageID].pyramid.loadedCount !== imageCount) { diff --git a/imagebox3.mjs b/imagebox3.mjs index 57eaf69..b11d3c8 100644 --- a/imagebox3.mjs +++ b/imagebox3.mjs @@ -1,6 +1,6 @@ // DO NOT USE THIS FILE IN SERVICE WORKERS. USE imagebox3.js INSTEAD. -import { fromUrl, Pool } from "https://cdn.jsdelivr.net/npm/geotiff@2.0.7/+esm" +import { fromBlob, fromUrl, Pool } from "https://cdn.jsdelivr.net/npm/geotiff@2.0.7/+esm" const imagebox3 = (() => { @@ -197,7 +197,7 @@ const imagebox3 = (() => { try { const headers = cache ? { headers: {'Cache-Control': "no-cache, no-store"}} : {} - tiff[imageID].pyramid = tiff[imageID].pyramid || ( await fromUrl(imageID, headers) ) + tiff[imageID].pyramid = tiff[imageID].pyramid || ( imageID instanceof File ? await fromBlob(imageID) : await fromUrl(imageID, headers) ) const imageCount = await tiff[imageID].pyramid.getImageCount() if (tiff[imageID].pyramid.loadedCount !== imageCount) {