2014-10-01 120 views
5

我使用這個jQuery的圖片上傳插件 https://github.com/blueimp/jQuery-File-Upload藍小鬼文件上傳的客戶端大小圖像的大小調整和作物

我需要做的是調整大小/作物客戶端大小的圖像,所以它具有精確的高度和寬度,然後上傳到服務器。

這是上傳腳本的一部分,它工作正常,唯一的問題是,它只是調整圖像的大小而不裁剪,並最終使用例如上傳的圖像。寬度爲150像素,高度爲133像素(儘管初始圖片的高度和寬度大於1000像素,我想要精確的高度和寬度 - 150像素)。從選項列表我認爲imageCrop應該做的伎倆,https://github.com/blueimp/jQuery-File-Upload/wiki/Options#imagecrop,但它沒有。我做錯了什麼,或者插件不支持我需要的功能?如果是這樣,有什麼辦法可以實現我需要使用這個插件使用一些外部庫/函數?

感謝

編輯:

我也試過這個選項,以及

canvas: true, 
cover: true, 
crop: true, 
thumbnail: true, 
aspectRatio: '1/1' 

但無濟於事

$('#fileupload').fileupload({ 
    url: 'test.php' 
    dataType: 'json', 
    imageCrop: true, 
    process: [ 
     { 
      action: 'load', 
      fileTypes: /^image\/(gif|jpeg|png)$/, 
      maxFileSize: 20000000 // 20MB 
     }, 
     { 
      action: 'resize', 
      maxWidth: 150, 
      maxHeight: 150, 
      minWidth: 150, 
      minHeight: 150, 
      imageCrop: true 
     }, 
     { 
      action: 'save' 
     }, 
     {action: 'duplicateImage'}, 
     { 
      action: 'resize', 
      maxWidth: 100, 
      maxHeight: 100, 
      minWidth: 100, 
      minHeight: 100, 
      imageCrop: true 
     }, 
     { 
      action: 'save' 
     } 
    ], ... 

回答

1

按照 「blueimp」 手工做Client side Image Resizing你必須等選項disableImageResizefalse

$('#fileupload').fileupload({ 
    url: 'test.php', 
    dataType: 'json', 
    disableImageResize: false, 
    imageMaxWidth: 800, 
    imageMaxHeight: 800, 
    imageCrop: true 
}) 

Reference to src.