Skip to content

Commit

Permalink
ImageBox3 works with local files
Browse files Browse the repository at this point in the history
  • Loading branch information
PrafulB committed Jan 30, 2024
1 parent e6d425f commit 3a0f2dc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules
package.json
package-lock.json
libopenjpeg*
1 change: 0 additions & 1 deletion demo/serviceWorker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion imagebox3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions imagebox3.mjs
Original file line number Diff line number Diff line change
@@ -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/[email protected]/+esm"
import { fromBlob, fromUrl, Pool } from "https://cdn.jsdelivr.net/npm/[email protected]/+esm"

const imagebox3 = (() => {

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3a0f2dc

Please sign in to comment.