公司最近需求 需要加载tiff图片
网上查找了很多例子 发现一个很好的库 tiff.js
http://seikichi.github.io/tiff.js/basic.html

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());github 地址https://github.com/seikichi/tiff.js/
版权声明:本文为qq_27970999原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。