t***@126.com
t***@126.com
  • 发布:2018-10-20 11:00
  • 更新:2018-10-20 11:20
  • 阅读:1938

我就想知道android下如何压缩图片并上传

分类:uni-app

求求各位谁来告诉我安卓下如何压缩并上传,不上传原图

2018-10-20 11:00 负责人:无 分享
已邀请:
k***@126.com

k***@126.com


            //压缩图片,src:图片数据,index:开始压缩的数组下标  
            function compressImage(src,index){  
                if(index==0)imgArr=[];  
                var newupimg=getUid();  
                plus.zip.compressImage({  
                        src:src[index],//需要压缩的图片路径  
                        dst:"_doc/"+newupimg+".jpg",保存的图片路径  
                        width:'1000px',//压缩后图片宽度  
                        quality:80,//图片质量  
                        overwrite:true//是否覆盖  
                    },  
                    function() {  
                        imgArr.push("file://"+plus.io.convertLocalFileSystemURL("_doc/"+newupimg+".jpg"));  
                        if((index+1)>=src.length){  
                            showimg();  
                        }else{  
                            compressImage(src,index+1)  
                        }  
                    },function(error) {  
                        console.log('图片未压缩');  
                });  
            }

该问题目前已经被锁定, 无法添加新回复