如何为dropzone生成tiff缩略图

时间:2015-06-09 19:44:08

标签: javascript dropzone.js

Dropzone提供了以下有关生成自定义缩略图图像的说明:

myDropzone.on("addedfile", function(file) {
   if (!file.type.match(/image.*/)) {
      // This is not an image, so Dropzone doesn't create a thumbnail.
      // Set a default thumbnail:
      myDropzone.emit("thumbnail", file, "http://path/to/image");

      // You could of course generate another image yourself here,
      // and set it as a data url.

我现在可以使用以下方法将二进制图像数据读入我的tif_canvas对象:

      var reader = new FileReader();   
      reader.onload = function (event) {
         var buffer = event.target.result;
         var tiff = new Tiff({ buffer: buffer });
         var tif_canvas = tiff.toCanvas();
         var width = tiff.width();
         var height = tiff.height();
         console.log(width + "x" + height);
      };

      reader.onerror = function (event) {
          console.error("File could not be read! Code " + event.target.error.code);
      };

      reader.readAsArrayBuffer(file);

   }
});

如何将tif_canvas设置为.emit(“缩略图”,文件,URL)中的dropzone缩略图URL我该怎么办?

0 个答案:

没有答案
相关问题