Implementation of a TileSource for OpenSeadragon based on geotiff.js, enabling local and remote TIFF files to be viewed without using an image server.
Implements an ES6 module extending the original work from pearcetm/GeoTIFFTileSource. For further information on creating GeoTIFF files and it's requirements, please see the original repository.
The plugin is available as an npm package:
npm i geotiff-tilesource
The plugin requires OpenSeadragon 3.0.0 or above, and includes geotiff.js as a dependency.
The plugin allows for extending OpenSeadragon with a new TileSource
type, the GeoTIFFTileSource
. To initialize, call the following at the top-most import of OpenSeadragon:
import OpenSeadragon from 'openseadragon';
import { enableGeoTIFFTileSource } from "geotiff-tilesource";
enableGeoTIFFTileSource(OpenSeadragon);
This will make the OpenSeadragon.GeoTIFFTileSource
class available for use.
GeoTIFFTileSource accepts both local and remote GeoTIFF files. For local files, the url
parameter should be a File
object. For remote files, the url
parameter should be a string. The getAllTileSources
reads a local or remote GeoTIFF file and returns an array of OpenSeadragon.GeoTIFFTileSource
objects, one for each image (page) in the GeoTIFF file.
const tiffTileSources = await OpenSeadragon.GeoTIFFTileSource.getAllTileSources(remoteUrl, {
logLatency: false,
});
The OpenSeadragon.Viewer
can be created as usual, with the tileSources
parameter set to the array of OpenSeadragon.GeoTIFFTileSource
objects, or with the viewer.open
method.
const viewer = new OpenSeadragon.Viewer({
id: 'viewer',
crossOriginPolicy: "Anonymous",
ajaxWithCredentials: true,
tileSources: tiffTileSources,
...viewerOptions,
});
// OR
viewer.open(tiffTileSources);