js里面
var requestCallback = function (err, data) {//请求结果
({//获取这个图片 图片压缩
src: files[filescount],//需要获取的图片 图片选择不用我说了吧
success: function (res) {
var ctx = ('photo_canvas');//使用一个canvas
var canvasWidth = //原图宽度
var canvasHeight = ;//原图高度
var tWidth = 800; //设置缩略图初始宽度 //可调
var tHeight = 640; //设置缩略图初始高度 //可调
if (canvasWidth > tWidth || canvasHeight > tHeight) {
//按比例计算出缩略图的宽度和高度
if (canvasWidth > canvasHeight * 1.8) {
tHeight = (parseFloat(canvasHeight) * (parseFloat(tWidth) / parseFloat(canvasWidth)));
}
else {
tWidth = (parseFloat(canvasWidth) * (parseFloat(tHeight) / parseFloat(canvasHeight)));
}
}
else {
tWidth = canvasWidth;
tHeight = canvasHeight;
}
//绘制新图
(files[filescount], 0, 0, tWidth, tHeight)
()
//下载canvas图片
setTimeout(function () {
({
canvasId: 'photo_canvas',
success: function (res) {
var filePath =
var oldfilePath = files[filescount] //下面是我的调用腾讯云存储对象业务 不需要可删除
var Key = (('/') + 1);
var yskeyCl = ('.')
var yskey = yskeyCl[2] + '-ys.' + yskeyCl[3]
({
Bucket: ,
Region: ,
Key: yskey,
FilePath: filePath
}, function (err, data) {
JiaruFile(yskeyCl[2] + '.' + yskeyCl[3])//加入数据库
filescount = filescount + 1
zhixing()//这是并发控制 根据业务自行处理
});
},
fail: function (error) {
(error)
}
})
}, 100)
}
})
}
页面要加上这个哦