Commit 4be91f3
committed
Fix: Apply PNG quantization only to true indexed images with ≤ max colors
This refines the logic introduced in [59589] to prevent image quality degradation
on resized PNGs. Quantization is now only applied when:
- The image is indexed (color-type-orig == 3)
- The actual color count (getImageColors) is ≤ the max allowed by bit depth
This preserves the original optimization goals (palette size reduction) while
preventing unintended degradation on full-color or gradient-rich images.
Also maintains grayscale (png8) support and alpha channel chunk handling.
Props @SirLouen @siliconforks @wildworks
Fixes #634481 parent f6ed800 commit 4be91f3
1 file changed
+10
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | | - | |
| 488 | + | |
489 | 489 | | |
490 | | - | |
491 | | - | |
| 490 | + | |
| 491 | + | |
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | | - | |
| 498 | + | |
499 | 499 | | |
500 | 500 | | |
| 501 | + | |
501 | 502 | | |
502 | 503 | | |
503 | 504 | | |
504 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
505 | 508 | | |
506 | | - | |
| 509 | + | |
507 | 510 | | |
508 | 511 | | |
509 | 512 | | |
510 | 513 | | |
511 | | - | |
512 | | - | |
513 | | - | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
| |||
0 commit comments