compressorjs
compressorjs copied to clipboard
IOS无法压缩JPG格式的图
图像大小为18M, 参数为quality: 0.6, convertTypes: ["*"], convertSize: 10000000,同样一张图安卓是没问题的
可能是超出 iOS 内存限制,试试将 checkOrientation
属性设为 false
。
我设置了 { strict: true, checkOrientation: false, quality: 0.6, convertTypes: ["image/png", "image/webp"], convertSize: 3000000, } jpeg格式的图片,ios还是无法压缩图片,安卓是可以的; 苹果拍照上传的图片是heif格式的没有这个问题
估计还是浏览器内存上限问题,实在不行,可以考虑上传到服务端进行压缩。
我测试了下,同一个 27.4M 的 jpg 图片,使用 https://donaldcwl.github.io/browser-image-compression/example/basic.html 是可以正常压缩的。可能不是内存问题?
@fengyuanchen 是浏览器 canvas 有个宽高限制。 ios 只有 4096 x 4096,图片宽高超了时,就无法正常 draw。
@xiaweiss 文档 maxWidth
参数有最大 4096 提示:https://github.com/fengyuanchen/compressorjs?tab=readme-ov-file#maxwidth