Comments (5)
Yes, pngquant calculates mean square error, and applies dithering only in areas with high error. This way areas that don't need dithering don't get the extra noise.
pngquant also does edge detection (similar to Prewitt algorithm) and disables dithering on the edges. This prevents anti-aliasing look like fur.
In pngquant 90% of time is spent on extra runs of K-means. If you use --speed 10
the whole recompression (on i7 2.3Ghz) takes ~80ms dithered, 50ms undithered.
(BTW, TinyPNG doesn't have its own algorithm. It's just a GUI for pngquant).
from upng.js.
I implemented Floyd-Steinberg dithering in the past, but it was not worth it.
I think we need some compression-friendly dithering. Do you know anybody who could help us?
from upng.js.
pngquant uses Floyd-Steinberg modified for better color handling.
I believe, that dithering will always increase filesize because of its' random nature.
Only purpose of this feature — to pleasure our eyes.
Dithering can be hidden under flag, just like in Ps. Users will decide.
I think we need some compression-friendly dithering. Do you know anybody who could help us?
I think, we may ask @kornelski.
from upng.js.
I mean, I made three versions of image:
- A: 50 colors: 15 kB
- B: 50 colors + Dithering: 23 kB
- C: 100 colors: 22 kB
B looked as nice as C, but was slightly larger, so I thought that allowing more colors is better than dithering (both increase the file size).
I think we need dithering, that consists of some repetitive patterns, i.e. it should be "friendly" to Deflate algorithm - make B have only 20 kB (so it is still as nice as C, but smaller).
BTW. I also think, that pngquant performs a better Deflate (which also takes about 100x more time than UPNG.js: e.g. 30ms vs. 3000ms), so it can make B have only 20 kB, while using the same dithering as I did.
from upng.js.
Oh, I see.
I don't know dithering algorithm, that can handle this case.
pngquant computes mse error, have min and max quality settings and don't write file if its' size too big or quality degrades dramatically.
Maybe you find this thread useful
https://encode.ru/threads/1757-Lossy-DEFLATE-lossy-PNG
And this project particually
https://github.com/foobaz/lossypng
from upng.js.
Related Issues (20)
- tabs / loop parameter HOT 1
- Encode PNG with specific palette and samples information HOT 1
- Inflation algorithm used for decoding can go into infinite loop HOT 2
- LGTM.com issues in UPNG.js HOT 1
- APNG images at second index until <numimages> gets offset and gets wrong size HOT 9
- How do I encode my ImageData 1-to-1, keeping #12345600 color (RGBA) as it is, not dropping to #00000000? HOT 1
- Uncaught RangeError: byte length of Uint32Array should be a multiple of 4 HOT 5
- Reduce colors of raw ImageData without having to encode then decode a PNG HOT 3
- " Cannot read properties of undefined (reading 'deflate') " HOT 1
- Make png image transparent from reference image HOT 6
- How to tell if my pixel data is incorrect or my code is incorrect HOT 2
- Why use UZIP only when the data length is greater than 10e6? HOT 2
- Check for optional UZIP dependency throws error (for large images) HOT 3
- Make it tree-shakable HOT 10
- Image resizing HOT 1
- Output PNG file size not deterministic HOT 2
- Support for more compression HOT 2
- Uncaught TypeError: Cannot read properties of undefined (reading 'inflate') HOT 3
- 使用upng压缩png图片水波纹比较重,这个大家怎么解决的 HOT 1
- How to resolve this issue? Kindly help HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from upng.js.