npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geotiff-tilesource

v2.0.2

Published

A plugin tilesource for OpenSeadragon that uses geotiff.js to provide serverless access to view compatible local or remote TIFF files

Downloads

126

Readme

GeoTIFFTileSource

Implementation of a TileSource for OpenSeadragon based on geotiff.js, enabling local and remote TIFF files to be viewed without using an image server.

See it in action at https://pearcetm.github.io/GeoTIFFTileSource/demo/demo.html

How to create GeoTIFF files

In order to generate a GeoTIFF file compatible with this library, you can for instance use sharp, a High performance Node.js image processing library.

import sharp from 'sharp'

sharp('input.jpg', {limitInputPixels:false})
    .tiff({tile:true, pyramid:true})
    .toFile('output.tiff')
    .then(console.log)
    .catch(console.error);

Many options are available.

Check sharp documentation on TIFF output format.

Prerequisites for remote files - HTTP range requests

This library works by loading only parts of the remote TIFF file (which may be huge). For this, the remote http server has to be compatible. Most production-ready http servers are compatible, but some development servers (such as python3 -m http.server or PHP built-in development web server) are not.

Check Mozilla documentation on HTTP range requests.

Usage

Installation

The plugin is available as both an npm package and a standalone script.

Using NPM

npm i geotiff-tilesource

Using standalone scripts

Standalone scripts for the plugin are available as both UMD and ES module scripts. The UMD script is compatible with the OpenSeadragon global object, while the ES module script can be imported as a module. Note that the OpenSeadragon library must be loaded before the plugin script. The geotiff.js library comes bundled with the plugin, and does not need to be loaded separately.

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.0/openseadragon.min.js"></script>

<!-- Using UMD script -->
<script type="text/javascript" src="geotiff-tilesource.min.js"></script>
<!-- Using ES module script -->
<script type="module" src="geotiff-tilesource.mjs"></script>

Extending OpenSeadragon

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:

Using NPM package

import OpenSeadragon from 'openseadragon';
import { enableGeoTIFFTileSource } from "geotiff-tilesource";

enableGeoTIFFTileSource(OpenSeadragon);

Using standalone scripts

Using UMD script

The UMD script will automatically extend the OpenSeadragon global object with the GeoTIFFTileSource class.

Using ES module script
import { enableGeoTIFFTileSource } from './geotiff-tilesource.mjs';

enableGeoTIFFTileSource(OpenSeadragon);

This will make the OpenSeadragon.GeoTIFFTileSource class available for use.

Using the GeoTIFFTileSource

Prepare TileSources

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,
  });

Create OpenSeadragon Viewer

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);