上传的文件大了可以压缩,压缩的时候选择压缩图片质量,输入压缩的值为90的时候,大概可以压缩到1/6大小,质量不太受影响,亲测
/*再对图片进行压缩为再上传到服务器*/
var resizeImage = function(srcImg,tagImgWidth,quality,name,src){
console.log("src="+src);
plus.zip.compressImage({
src: src,
dst: '_doc/'+name,
overwrite: true,
//width: '270px', //这里指定了宽度,同样可以修改
//format: 'jpg',
quality: quality //图片质量不再修改,以免失真
},function(rst) {
console.log("rst="+JSON.stringify(rst));
/*将压缩完的图片添加到上传容器*/
addSignImgFn(srcImg,tagImgWidth,rst.target);
},function(err) {
console.log("err="+JSON.stringify(err));
msgCallback("压缩文件失败,请务必选择图片类文件");
});
}
3472422B;3391.04K;3.31M;IMG_20170412_164510_AO_HDR.jpg;Wed Apr 12 2017 16:45:10 GMT+0800 (CST) at sign_img_upload.html:177
src=file:///storage/emulated/0/DCIM/Camera/IMG_20170412_164510_AO_HDR.jpg at sign_img_upload.html:151
rst={"target":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/apps/HBuilder/doc/IMG_20170412_164510_AO_HDR.jpg","width":1560,"height":2080,"size":542606}
2 个回复
赵梦欢 - 专注前端,乐于分享!
UploadOptions JSON对象,创建上传任务的参数支持分块上传,blocksize: (number 类型 )上传任务每次上传的文件块大小(仅在支持断点续传的服务有效)
y***@126.com
上传的文件大了可以压缩,压缩的时候选择压缩图片质量,输入压缩的值为90的时候,大概可以压缩到1/6大小,质量不太受影响,亲测
3472422B;3391.04K;3.31M;IMG_20170412_164510_AO_HDR.jpg;Wed Apr 12 2017 16:45:10 GMT+0800 (CST) at sign_img_upload.html:177
src=file:///storage/emulated/0/DCIM/Camera/IMG_20170412_164510_AO_HDR.jpg at sign_img_upload.html:151
rst={"target":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/.HBuilder/apps/HBuilder/doc/IMG_20170412_164510_AO_HDR.jpg","width":1560,"height":2080,"size":542606}