I'm trying to resize the image in the thumbnail to fix the box size. I've tried this :
我试着调整缩略图中的图像大小来固定盒子大小。我已经试过这个:
Dropzone.options.myAwesomeDropzone = {
maxFiles: 20,
maxFilesize: 2,
maxThumbnailFilesize: 20,
acceptedFiles: 'image/*,.jpg,.png,.jpeg',
thumbnailWidth:"250",
thumbnailHeight:"250",
init: function() {
var dropzone = this, xhrs = [];
$.each(uploadedImages, function (index, path) {
var xhr = new XMLHttpRequest();
xhr.open('GET', path);
xhr.responseType = 'blob';//force the HTTP response, response-type header to be blob
xhr.onload = function() {
var file = new File([xhr.response], '', {'type': xhr.response.type});
//dropzone.addUploadedFile(file);
dropzone.emit("addedfile", file);
dropzone.emit("thumbnail", file, path);
dropzone.emit("complete", file);
};
xhrs.push(xhr);
xhr.send();
});
this.options.maxFiles = this.options.maxFiles - uploadedImages.count;
}
};
This is the original Image how it looks : http://files.parsetfss.com/12917a88-ac80-4e5e-a009-fc634161b79c/tfss-6c59b59f-8f57-4610-966e-31bbc203707b-samsung-galaxy-note-4-7290-002.jpg
这是最初的图片:http://files.parsetfss.com/12917a88-ac80-4e5e-a009-fc634161b79c/tfss- 6c59f -8f57-4610-966e-31bbc203707b-samsung-galaxy-note-4-7290-002.jpg。
And this is how it's displayed :
它是这样显示的:
Also I've tried :
我也试过:
thumbnailWidth:"300",
thumbnailHeight:"300",
===
thumbnailWidth:"400",
thumbnailHeight:"400",
But nothing changed, thumbnailWidth and thumbnailHeight
have no effect
但是没有改变,拇指宽度和拇指高度没有影响
2 个解决方案
#1
1
You can size a new image explicitly in javascript.
您可以在javascript中显式地调整一个新图像的大小。
var img = new Image();
img.src = 'http://files.parsetfss.com/12917a88-ac80-4e5e-a009-fc634161b79c/tfss-6c59b59f-8f57-4610-966e-31bbc203707b-samsung-galaxy-note-4-7290-002.jpg';
img.height = 300;
img.width = 300;
img
is now resized with proper dimensions.
img现在以合适的尺寸调整大小。
Also, I just looked at the dropzone.js documentation and this method is probably of use. http://www.dropzonejs.com/#config-resize
另外,我只看了dropzone。js文档和这个方法可能是有用的。http://www.dropzonejs.com/ config-resize
#2
6
I had the same problem, but if you call manually the resize function of the dropzone, the thumnails will be in the right dimensions:
我也有同样的问题,但是如果你手动调用dropzone的resize函数,它会在正确的维度上:
var file = new File([xhr.response], '', {'type': xhr.response.type});
dropzone.createThumbnailFromUrl(file,path);
dropzone.emit("addedfile", file);
dropzone.emit("thumbnail", file, path);
dropzone.emit("complete", file);
#1
1
You can size a new image explicitly in javascript.
您可以在javascript中显式地调整一个新图像的大小。
var img = new Image();
img.src = 'http://files.parsetfss.com/12917a88-ac80-4e5e-a009-fc634161b79c/tfss-6c59b59f-8f57-4610-966e-31bbc203707b-samsung-galaxy-note-4-7290-002.jpg';
img.height = 300;
img.width = 300;
img
is now resized with proper dimensions.
img现在以合适的尺寸调整大小。
Also, I just looked at the dropzone.js documentation and this method is probably of use. http://www.dropzonejs.com/#config-resize
另外,我只看了dropzone。js文档和这个方法可能是有用的。http://www.dropzonejs.com/ config-resize
#2
6
I had the same problem, but if you call manually the resize function of the dropzone, the thumnails will be in the right dimensions:
我也有同样的问题,但是如果你手动调用dropzone的resize函数,它会在正确的维度上:
var file = new File([xhr.response], '', {'type': xhr.response.type});
dropzone.createThumbnailFromUrl(file,path);
dropzone.emit("addedfile", file);
dropzone.emit("thumbnail", file, path);
dropzone.emit("complete", file);