网页预览tiff格式的图片

传送门,https://github.com/seikichi/tiff.js
代码:

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

默认10M大小,如果想突破限制,
实例化Tiff对象前,加入

Tiff.initialize({ TOTAL_MEMORY :50*1024*1024 });//支持最大50M

你可能感兴趣的:(网页预览tiff格式的图片)