Simplify alpha premultiplication, now supported by sharp #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Maplibre-native outputs premultiplied pixels values. The sharp library did not support it so we added code to cancel the alpha premultiplication. Note that this can only visible on raster tiles (and probably static maps).
The sharp library now supports premultiplied pixels with the right config. Let's use it: it should be faster and easier to maintain.
Feature announced here:
lovell/sharp#1599 (comment)
Feature developped here by @mnutt:
lovell/sharp#2685
Raster Before
Raster After (visually identical)
Vector for comparison (with building shadow)
What the problem used to look like
For reference, here is the same zone when premultiplication is not cancelled and
![image](https://private-user-images.githubusercontent.com/242172/284333836-186bfb9c-8a12-4aa3-9836-70c5409c53ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM0OTY5MDksIm5iZiI6MTcyMzQ5NjYwOSwicGF0aCI6Ii8yNDIxNzIvMjg0MzMzODM2LTE4NmJmYjljLThhMTItNGFhMy05ODM2LTcwYzU0MDljNTNhYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODEyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxMlQyMTAzMjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMjRlYzZjN2MzMjJkMTU2ZmMzMTQyMmZjZjdiZjU4MDM1ZDY2NmNhYWI4YTUxMWNiOTZmZmYwZmIwOTBjZmJmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.2wU5iIpRtbZ_bgaAP1ydVKJUFnhlSDXH4Rx6SjZMcxQ)
premultiplied: true
is not set.