上传图片质量问题,原图上传,500K变成130几K,8M的图片变成了4M
发布于 5 年前 作者 tanjie 3573 次浏览 来自 问答

在iphone(ios 11.3)真机测试小程序上传时,选择原图上传,控制台查看图片信息tempFiles,发现size只有原图的一半大小,上传成功完成后,服务器上看也只有原图一半大小。为什么?选了原图上传还会自动压缩图片?500K变成130几K,8M的图片变成了4M.

chooseImage: function (e) {
    var that = this;

    var currentid = e.currentTarget.id;


    wx.chooseImage({
        count:1,
        sizeType: ['original', 'compressed'],
        sourceType: ['album'],

        success: function (res) {


          console.log(res); ## 这里就可以看到选择的图片size已经被压缩掉一半了
 
            var lefthand = that.data.lefthand,
                righthand = that.data.righthand,
                face = that.data.face;
 
            var files = [];
            switch (currentid){
              case 'lefthand':
                lefthand = res.tempFilePaths[0];
              break;
              case 'righthand':
                righthand = res.tempFilePaths[0];
              break;
              case 'face':
                face = res.tempFilePaths[0];
              break;
            }
 
            wx.getImageInfo({
              src:lefthand,
              success:function(res){
                console.log(res);
              }
            });
 
            files.push(lefthand);
            files.push(righthand);
            files.push(face);
 
            that.setData({
                files: files,
                lefthand: lefthand,
                righthand:righthand,
                face:face
            });
 
        }
    })
},
4 回复

有没有人解决?

wechatide://minicode/NxJZuLmw6bZM

同样的问题,在ios上上传会自动压缩,Android上不会压缩,上传一个10.8M(11324620.8B)的图片,结果返回的只有8M左右(8639999B)了

请问解决了吗?我这边也存在着这样的问题,在ios真机上原图大概被压缩2倍多一点点

回到顶部