wx.compressImage的压缩问题,及电脑开发工具,跟安卓手机不一样等问题?

小程序 文章 2022-03-25 05:40 0 全屏看文

wx.compressImage的压缩问题,及电脑开发工具,跟安卓手机不一样等问题?The compression problem of wx.compressImage, and the computer development tools, are not the same as Android phones?

wx.compressImage的压缩问题,及电脑开发工具,跟安卓手机不一样等问题?

我发现用这个wx.compressImage方法来压缩jpg文件有很大的问题。

问题一,用‘微信开发者工具’(下面简称:电脑)跟手机‘开发版’上传同一张图片。压缩后的体积不一样。这里用了一张 1.47 MB= 1537177 Byte大小的图片。电脑上传的是

手机上传得到的是:

明显的看得出区别非常大,,,,,

还有一个问题,就是手机上传,用了压缩方法的比原来的图片还大!!

原来!264.01 KB= 270350 Byte

压缩后!296.56 KB= 303678 Byte

我很不解。。。。。


代码在这里:

//增加图片 选项图片

    addImageTap(e) {

        let that = this

        let tempFiles = this.data.tempFiles

        wx.chooseMedia({

            count: 9,

            sizeType: ['original', 'compressed'],

            sourceType: ['album'],

            success(res) {

                console.log(res)

                if (res.type == "video"{

                    wx.showToast({

                        title: '目前暂不支持上传视频。',

                        icon: 'none',

                        duration: 3000

                    })

                    return

                }

                console.log(res.tempFiles[0].tempFilePath)

                wx.getImageInfo({

                    src: res.tempFiles[0].tempFilePath,

                    success(res) {

                        console.log(res,'1111')

                    }

                })

                that.uploadingImage(res.tempFiles[0].tempFilePath)//上传到云存储

                wx.compressImage({

                    src: res.tempFiles[0].tempFilePath, // 图片路径

                    quality: 0, // 压缩质量

                    success(res) {

                        console.log(res)

                        that.uploadingImage(res.tempFilePath)

                        wx.getImageInfo({

                            src: res.tempFilePath,

                            success(res) {

                                console.log(res,'2222')

                            }

                        })

                    }

                })


                let arr = tempFiles.concat(res.tempFiles)

                that.setData({

                    tempFiles: arr

                })

            }

        })

    },

备注:我手机有点原图,为了严谨。原图跟压缩图,我都一起上传到云存储,所以不存在数据不对的问题。。。

 Byte

I found that with this Wx Compressimage method to compress JPG files has a big problem. Question 1: upload the same picture with the "wechat developer tool" (hereinafter referred to as "computer") and the "development version" of the mobile phone. The volume after compression is different. Here is a picture with the size of 1.47 MB = 1537177 bytes. What the computer uploads is from the mobile phone, and what you get is: obviously, there is a big difference. Another problem is that the mobile phone uploads, which uses the compression method, is larger than the original picture!! original! 264.01 KB = 270350 bytes after compression! 296.56 KB = 303678 byte I don't understand..... Here is the code: / / add the picture option picture addimagetap (E) {let that = this let tempfiles = this.data.tempfiles wx.choosemedia ({count: 9, sizetype: ['original ','compressed'], sourcetype: ['album '], success (RES) {console.log (RES) if (res.type = = "video") {wx.showtoast ({Title:' uploading video is not supported at present ', Icon:' none ', duration: 3000}) return} console log(res.tempFiles[0].tempFilePath) wx. getImageInfo({ src: res.tempFiles[0].tempFilePath, success(res) { console.log(res,'1111') } }) that. Uploadingimage (res.tempfiles [0]. Tempfilepath) / / upload to cloud storage Wx Compressimage ({SRC: res.tempfiles [0]. Tempfilepath, / / image path quality: 0, / / compression quality success (RES) {console.log (RES) that.uploadingimage (res.tempfilepath) wx.getimageinfo ({SRC: res.tempfilepath, success (RES) {console.log (RES, '2222')})}}) let arr = tempfiles concat(res.tempFiles) that. SetData ({tempfiles: arr})}}). Note: my mobile phone is a little original, for the sake of preciseness. The original image and compressed image are uploaded to cloud storage together, so there is no problem of wrong data... Byte

回答:

(๑• . •๑):

而且我还发现,用电脑压缩后的地址没有后缀。。。

222222:书
舍德:开心群
马尚尚:

本身存在,你不会才发现吧

-EOF-