Skip to content

Use PNG compression level 6 for Android resources - #535

Open
PrestaEdit wants to merge 2 commits into
NativePHP:mainfrom
PrestaEdit:fix/png-compression-level
Open

PrestaEdit wants to merge 2 commits into
NativePHP:mainfrom
PrestaEdit:fix/png-compression-level

Conversation

@PrestaEdit

Copy link
Copy Markdown
Contributor

Follow-up to #399. When android.image_format is png (the default), launcher icons and splash screens are written with imagepng(..., 9). Level 9 is very slow for a tiny size gain over zlib's default level 6. PNG compression is lossless, so the output pixels are identical either way.

Measured on a 1280×1920 xxxhdpi splash:

Level Size Time
0 (before #399) 7.04 MB 0.03 s
6 (this PR) 1.40 MB 0.53 s
9 (current) 1.28 MB 9.35 s

With up to 10 splash variants (5 densities × light/dark) plus icons, level 9 adds roughly a minute to every Android build for ~2% smaller files. The WebP path is unchanged.

Same level as the 3.x backport in #534. tests/Unit/Concerns passes.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Thanks for the numbers, that's a big build-time win. One small thing: the code comment right above the call in resizeImage() still says // Level 9 = max PNG compression.... Could you update it to match level 6 (e.g. note it's zlib's default and why 9 isn't worth the build time)?

@PrestaEdit

Copy link
Copy Markdown
Contributor Author

Done, updated the comment. Thanks!

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

Successfully merging this pull request may close these issues.

2 participants