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

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

AI助手支持GPT4.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-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
菜单http打头的网址为何不让保存?
phone进入小程序白屏?
存在云储存中的图片,在微信开发者工具中渲染层网络层错误,怎么解决啊?我们开几个人同时出现这样的问题。
微信红包异形封面?
微信小程序返回上一个页面时是否可以加提示框,然后根据用户的选择判断是返回还是留在当前页面?
随便看看
教育科技公司申请微信支付被拒绝? 3936
微信公众号免300认证教程 5045
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4363
小程序广告组件通过审核,但是小程序内没有显示广告? 4339
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8252
问题? 7471
如何快速搭建抽奖助手小程序(无需代码知识) 5148
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6206
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5714
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5293