Giter Site home page Giter Site logo

Comments (4)

meowtec avatar meowtec commented on August 17, 2024

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

from imagine.

ijrou avatar ijrou commented on August 17, 2024

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

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

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

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

from imagine.

jiaoting avatar jiaoting commented on August 17, 2024

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

from imagine.

jiaoting avatar jiaoting commented on August 17, 2024

还有这个软件
https://github.com/Lymphatus/caesium-image-compressor

from imagine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.