{"_id":"@abiswas97/geotiff-tilesource","name":"@abiswas97/geotiff-tilesource","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"@abiswas97/geotiff-tilesource","version":"0.3.0","description":"Implementation of a [TileSource](https://openseadragon.github.io/docs/OpenSeadragon.TileSource.html) for [OpenSeadragon](https://openseadragon.github.io/) based on [geotiff.js](https://geotiffjs.github.io/), enabling local and remote TIFF files to be view","main":"./dist/geotiff-tilesource.min.js","module":"./dist/geotiff-tilesource.mjs","exports":{".":{"import":"./dist/geotiff-tilesource.mjs","require":"./dist/geotiff-tilesource.min.js"}},"scripts":{"dev":"vite","build":"vite build","preview":"vite preview"},"type":"module","devDependencies":{"prettier":"3.2.5","vite":"^5.0.8"},"dependencies":{"geotiff":"^2.1.2"},"peerDependencies":{"openseadragon":"^3.0.0 || ^4.0.0"},"_id":"@abiswas97/geotiff-tilesource@0.3.0","gitHead":"c0cd345680fa7c9f9f48fcd94d47d3c0e5cd91ea","_nodeVersion":"20.11.1","_npmVersion":"10.7.0","dist":{"integrity":"sha512-scaNZCABefkP4d33an0uEDmmt2to38nQUiys6MODjGRel9lB7B0sTn8RuW+Pvxh86ji1JR2Y8MY4UZSfRSqLUA==","shasum":"6c5b86659ef754d4acc7374999c3bb412304f19c","tarball":"https://registry.npmjs.org/@abiswas97/geotiff-tilesource/-/geotiff-tilesource-0.3.0.tgz","fileCount":29,"unpackedSize":2618661,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNaaTaUfvJN37w5cKK7ifDbtVtwtCjD+HnIKP7eKo7LgIgWqTZjwm51bI3A9JMUn0p2SiqqIy5vq5urXXiiotd/So="}]},"_npmUser":{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"},"directories":{},"maintainers":[{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/geotiff-tilesource_0.3.0_1716746923712_0.03538849369107844"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-26T18:08:43.629Z","0.3.0":"2024-05-26T18:08:43.905Z","modified":"2024-05-26T18:08:44.177Z"},"maintainers":[{"name":"abiswas97","email":"avishek.biswas.1997@gmail.com"}],"description":"Implementation of a [TileSource](https://openseadragon.github.io/docs/OpenSeadragon.TileSource.html) for [OpenSeadragon](https://openseadragon.github.io/) based on [geotiff.js](https://geotiffjs.github.io/), enabling local and remote TIFF files to be view","readme":"# GeoTIFFTileSource\r\n\r\nImplementation of a [TileSource](https://openseadragon.github.io/docs/OpenSeadragon.TileSource.html) for [OpenSeadragon](https://openseadragon.github.io/) based on [geotiff.js](https://geotiffjs.github.io/), enabling local and remote TIFF files to be viewed without using an image server.\r\n\r\nSee it in action at [https://pearcetm.github.io/GeoTIFFTileSource/demo/demo.html](https://pearcetm.github.io/GeoTIFFTileSource/demo/demo.html)\r\n\r\n## How to create GeoTIFF files\r\n\r\nIn order to generate a GeoTIFF file compatible with this library, you can for instance use [sharp](https://sharp.pixelplumbing.com/), a *High performance Node.js image processing* library.\r\n\r\n```javascript\r\nimport sharp from 'sharp'\r\n\r\nsharp('input.jpg', {limitInputPixels:false})\r\n    .tiff({tile:true, pyramid:true})\r\n    .toFile('output.tiff')\r\n    .then(console.log)\r\n    .catch(console.error);\r\n```\r\n\r\nMany options are available.\r\n\r\n[Check sharp documentation on TIFF output format.](https://sharp.pixelplumbing.com/api-output#tiff)\r\n\r\n## Prerequisites for remote files - HTTP range requests\r\nThis 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.\r\n\r\n[Check Mozilla documentation on HTTP range requests.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests)\r\n\r\n## Usage\r\n\r\n### Installation\r\n\r\nThe plugin is available as both an npm package and a standalone script.\r\n\r\n#### Using NPM\r\n```bash\r\nnpm i geotiff-tilesource\r\n```\r\n\r\n#### Using standalone scripts\r\nStandalone 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.\r\nNote 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.\r\n\r\n```html\r\n<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.1.0/openseadragon.min.js\"></script>\r\n\r\n<!-- Using UMD script -->\r\n<script type=\"text/javascript\" src=\"geotiff-tilesource.min.js\"></script>\r\n<!-- Using ES module script -->\r\n<script type=\"module\" src=\"geotiff-tilesource.mjs\"></script>\r\n```\r\n\r\n### Extending OpenSeadragon\r\n\r\nThe plugin allows for extending OpenSeadragon with a new `TileSource` type, the `GeoTIFFTileSource`. To initialize, call the following at the top-most import of OpenSeadragon:\r\n\r\n#### Using NPM package\r\n```javascript\r\nimport OpenSeadragon from 'openseadragon';\r\nimport { enableGeoTIFFTileSource } from \"geotiff-tilesource\";\r\n\r\nenableGeoTIFFTileSource(OpenSeadragon);\r\n```\r\n\r\n#### Using standalone scripts\r\n\r\n##### Using UMD script\r\nThe UMD script will automatically extend the `OpenSeadragon` global object with the `GeoTIFFTileSource` class.\r\n\r\n##### Using ES module script\r\n```javascript\r\nimport { enableGeoTIFFTileSource } from './geotiff-tilesource.mjs';\r\n\r\nenableGeoTIFFTileSource(OpenSeadragon);\r\n```\r\n\r\nThis will make the `OpenSeadragon.GeoTIFFTileSource` class available for use.\r\n\r\n### Using the GeoTIFFTileSource\r\n\r\n#### Prepare TileSources\r\n\r\nGeoTIFFTileSource 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.\r\n\r\n```javascript\r\n const tiffTileSources = await OpenSeadragon.GeoTIFFTileSource.getAllTileSources(remoteUrl, {\r\n    logLatency: false,\r\n  });\r\n```\r\n\r\n#### Create OpenSeadragon Viewer\r\n\r\nThe `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.\r\n\r\n```javascript\r\nconst viewer = new OpenSeadragon.Viewer({\r\n  id: 'viewer',\r\n  crossOriginPolicy: \"Anonymous\",\r\n  ajaxWithCredentials: true,\r\n  tileSources: tiffTileSources,\r\n  ...viewerOptions,\r\n});\r\n\r\n// OR\r\nviewer.open(tiffTileSources);\r\n```\r\n","readmeFilename":"README.md"}