Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

要是能自动批量将图片压缩到设置的某个大小就好了 #165

Open
ijrou opened this issue Aug 15, 2023 · 4 comments
Open

要是能自动批量将图片压缩到设置的某个大小就好了 #165

ijrou opened this issue Aug 15, 2023 · 4 comments

Comments

@ijrou
Copy link

ijrou commented Aug 15, 2023

有大量图片,将其拖入到软件中会自动压缩到某个指定大小(不超过该大小),,,方便一些有上传限制大小的网站

@meowtec
Copy link
Owner

meowtec commented Sep 4, 2023

这个实现比较麻烦,只有压缩后才能知道大小,如果要实现,需要尝试压缩多次。而且有可能无论怎么压缩都达不到某个大小。

@ijrou
Copy link
Author

ijrou commented Sep 6, 2023

这个实现比较麻烦,只有压缩后才能知道大小,如果要实现,需要尝试压缩多次。而且有可能无论怎么压缩都达不到某个大小。

但是不得不说,这功能非常实用,比如自己的网站,有很多图片,如果原图上传或者不做压缩处理,占用带宽和服务器容量就非常多(虽然有对象存储和CDN,但是能减少一点是一点),如果就限制图片最大不能超过多少kb就非常不错;

其实尝试压缩多次这种方式未必不可,比如一张图片10M想压缩到1M,那么按照质量50%进行压缩,得到5M,再对这图进行质量的50%压缩,一直下去,直到小于1M就可以了。。。可以自定义设置递归深度,比如深度设置为3,超过3就表示压缩失败

要是最后无论如何压缩都不行的话,同样进行显示压缩失败。。。

@jiaoting
Copy link

对呀对呀,要是有这个功能就完美了。
目前我发现有一款“图压”的APP,可以实现制定大小压缩,他也是采用开源的部分代码,不知道他是怎么实现的。可以参考一下。https://tuya.xinxiao.tech/
这款软件很久没更新了,测试发现不支持heic格式压缩

@jiaoting
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants