Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为dropzone生成tiff缩略图_Javascript_Dropzone.js - Fatal编程技术网

Javascript 如何为dropzone生成tiff缩略图

Javascript 如何为dropzone生成tiff缩略图,javascript,dropzone.js,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",

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.
现在,我可以使用以下方法将二进制图像数据读入my 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中的dropzone缩略图URL(“缩略图”、文件、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();};reader.readAsArrayBuffer(文件);如何让dropzone使用tif_canvas作为缩略图?我找到了答案:var dataURL=tif_canvas.toDataURL();emit(“缩略图”、文件、数据URL);这使我的CIELab tiff成为dropzone表单中的缩略图!