Tiff.js
tiff.js is a port of LibTIFF by compiling the LibTIFF C code with Emscripten.
Install / Use
/learn @seikichi/Tiff.jsREADME
tiff.js
tiff.js is a port of the LibTIFF by compiling the LibTIFF C code with Emscripten.
Demo
Usage
Browser
Download tiff.min.js and load the script by yourself:
var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', "url/of/a/tiff/image/file.tiff");
xhr.onload = function (e) {
var tiff = new Tiff({buffer: xhr.response});
var canvas = tiff.toCanvas();
document.body.append(canvas);
};
xhr.send();
Node.js
$ npm install tiff.js
Example
// Usage: node this-file.js input.tiff
var Tiff = require('tiff.js');
var fs = require('fs');
var filename = process.argv[2];
var input = fs.readFileSync(filename);
var image = new Tiff({ buffer: input });
console.log(filename + ': width = ' + image.width() + ', height = ' + image.height());
API
see tiff.d.ts
Note
- ~~This library does not support JPEG-based compressed TIFF files~~
- Fixed by Tetedeiench
- When you load large tiff file, you will see the error message "Cannot enlarge memory arrays in asm.js"
- in such case, please call 'Tiff.initialize({TOTAL_MEMORY: ... })' before you create a Tiff instance
- This JavaScript library uses only some parts of the LibTIFF features
- To be more precise, I use following functions only
- TIFFOpen, TIFFClose, TIFFGetField, TIFFReadRGBAImage, TIFFSetDirectory, TIFFCurrentDirectory, TIFFReadDirectory
Alternatives
License
The LibTIFF is LibTIFF Software License, zlib and additional code are zlib License.
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
