我是Fineuploader的新手,并将这个伟大的上传器和Pica一起用于图像缩放。 Pica适用于缩放和缩略图。
scaling: {
sendOriginal: false,
hideScaled: false,
sizes: [
{name: "a", maxSize: 200},
{name: "b", maxSize: 600},
{name: "c", maxSize: 1000}
],
customResizer: !qq.ios() && function(resizeInfo) {
return new Promise(function(resolve, reject) {
pica.debug = console.log.bind(console),
pica.resizeCanvas(resizeInfo.sourceCanvas, resizeInfo.targetCanvas, {}, resolve)
})
}
}, thumbnails: {
customResizer: !qq.ios() && function(resizeInfo) {
return new Promise(function(resolve, reject) {
pica.resizeCanvas(resizeInfo.sourceCanvas, resizeInfo.targetCanvas, {}, resolve)
})
}
}
但是,我需要将其缩写到其他地方。我试过谷歌搜索并浏览Fineuploader的文档,但仍然没有运气使用绘图运行与绘图。
drawThumbnail (id, targetContainer[, maxSize[, fromServer[, customResizer]]])
var canvas = document.createElement('canvas');
canvas.width = 300;
canvas.height = 200;
$(".frame").html(canvas);
uploader.drawThumbnail(id, canvas, 300, false);
如果有人可以指导我修改当前代码以使用Pica运行drawThumbnail,那将是非常好的,谢谢。
答案 0 :(得分:1)
正如您在问题中指出的那样,文档显示了在使用drawThumbnail
时如何使用备用缩放器功能:
drawThumbnail(id, targetContainer[, maxSize[, fromServer[, customResizer]]])
...所以,你的代码看起来像这样:
var canvas = document.createElement('canvas')
var customResizer = function(resizeInfo) {
return new Promise(function(resolve, reject) {
pica.resizeCanvas(
resizeInfo.sourceCanvas,
resizeInfo.targetCanvas,
{},
resolve
)
})
}
canvas.width = 300;
canvas.height = 200;
$(".frame").html(canvas);
uploader.drawThumbnail(id, canvas, 300, false, !qq.ios() && customResizer);