Reading tiff using libtiff, compiled to webassembly.
Inspired by loam (Worker and wasm communication architecture) - https://github.com/azavea/loam
Using libtiff wasm - https://github.com/Twinklebear/tiff.js
- Run
npm install --save libtiffjs
- Install file-loader:
npm install --save-dev file-loader
- Add the following alias to webpack config file:
libtiffjs: path.join(__dirname, 'node_modules', 'libtiffjs', 'lib')
- Load libtiffjs files using file-loader (add to webpack config):
{
test: /(libtiff-worker\.js|tiff\.raw\.wasm|tiff\.raw\.js)$/,
type: 'javascript/auto',
loader: 'file-loader?name=[name].[ext]',
}
- To load the library in your code:
import * as libtiffjs from 'libtiffjs';
require('libtiffjs/libtiff-worker.js');
require('libtiffjs/tiff.raw.js');
require('libtiffjs/tiff.raw.wasm');
libtiffjs.initialize();
https://libtiffjs.netlify.app
The demo code is available here:
https://github.com/aviklai/libtiffjs-example