Issue Fix for #2958 Transparent backgrounds on PNG images lost in dynamic media Urls
| Q | A |
|---|---|
| Fixed Issues? | Fixes #2958 |
| Patch: Bug Fix? | |
| Minor: New Feature? | Yes |
| Major: Breaking Change? | |
| Tests Added + Pass? | Yes |
| Documentation Provided | Yes (markdown) |
| Any Dependency Changes? | |
| License | Apache License, Version 2.0 |
Conditional PNG Transparency Detection
Rather than applying fmt=png-alpha to all PNGs (which would cause significant performance issues), we can automatically detect which PNGs actually have transparency using existing DAM metadata.
Key Insight: dam:Bitsperpixel metadata reliably indicates PNG transparency:
32bits = PNG with alpha channel (transparent) → Addfmt=png-alpha24bits = RGB PNG (opaque) → No format modifier needed8bits = Indexed PNG (opaque) → No format modifier needed
Implementation: Modify the Dynamic Media URL building logic in ImageImpl.java to automatically prepend fmt=png-alpha only when dam:Bitsperpixel = 32 for PNG assets.
Benefits:
- ✅ Preserves transparency automatically for transparent PNGs
- ✅ Maintains optimal performance for non-transparent PNGs
- ✅ Zero breaking changes - existing manual configurations still work
- ✅ Can be policy-controlled via
autoPreservePngTransparencysetting
This approach solves the transparency issue while completely avoiding the performance penalty since fmt=png-alpha is only applied when transparency actually exists.
Codecov Report
:x: Patch coverage is 9.09091% with 40 lines in your changes missing coverage. Please review.
:loudspeaker: Thoughts on this report? Let us know!
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code