donglong2856 2016-10-08 13:09
浏览 105
已采纳

使用imagemagick和uploadcare显示PSD,PDF文件类型的缩略图

I have a form where users can upload files using uploadcare widget. Once uploaded I can output/show the preview, but only if the file type is image like jpg, png etc. But I need to be able to show for other file types like PSD, PDF as well. I am trying to implement imagemagick for this, but confused how to use it with uploadcare as the widget uses jquery to fetch image cdn. Whereas most tutorial I found online are for php.

You can have a look at the widget snippet in this fiddle: https://jsfiddle.net/kamela101/e6ac6jb4/

$ = uploadcare.jQuery;
  // Create uploaded image list and append additional form fields to each item
  function installWidgetPreviewMultiple(widget, list) {
    widget.onChange(function(fileGroup) {
      list.empty();
      if (fileGroup) {
        $.when.apply(null, fileGroup.files()).done(function() {

          $.each(arguments, function(i, fileInfo) {
            // display file preview
            var $filename = fileInfo.name;// display file name
            var $fileurl = fileInfo.cdnUrl;// get file url
            var $src = fileInfo.cdnUrl + '-/resize/100x100/filename.jpg';// preview image source, resize to 100X100px and jpeg file type
            // append preview and name and form fields to each file uploaded inside thumb_list 
            list.append(
              $('<li class="thumb_list_item"><img src="' + $src+ '" alt="File Preview" class="preview-img">' + '<h4 class="filename">' + $filename + '</h4>' + '<div class="get-layer-wraper"><ul class="get-layer"><li class="layer-name"><label for="white-layer" class="layer-title">White Layer : </label></li><li><input id="white-layer" name="white-layer[]" class="layer" type="number" value="0"></li><li>PX</li></ul><div class="clear"><ul class="get-layer"><li class="layer-name"><label for="adhesive-layer" class="layer-title">Adhesive Layer : </label></li><li><input id="adhesive-layer" name="adhesive-layer[]" class="layer" type="number" value="0"></li><li>PX</li></ul><div class="clear"><ul class="get-layer"><li class="layer-name"><label for="block-layer" class="layer-title">Blocking Layer : </label></li><li><input id="block-layer" name="block-layer[]" class="layer" type="number" value="0"></li><li>PX</li></ul><div class="clear"><ul class="get-layer"><li class="layer-name"><label for="clear-layer" class="layer-title">Clear Layer : </label></li><li><input id="clear-layer" name="clear-layer[]" class="layer" type="number" value="0"></li><li>PX</li></ul></div></li>').appendTo(".thumb_list")
              );
          });
        });
      }
    });
  }
$(function() {
  $('.upload-area').each(function() {
    installWidgetPreviewMultiple(
      uploadcare.MultipleWidget($(this).children('input')),
      $(this).children('.thumb_list')
    );
  });
});
  • 写回答

1条回答 默认 最新

  • douxin20081125 2016-10-10 15:45
    关注

    Uploadcare doesn't support PSD and PDF preview functionality as of now. You would have to use a third-party service that allows you to do that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口