Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alpha band values when storing Uint16 data in PNG #407

Merged
merged 2 commits into from
Jul 29, 2021

Conversation

vincentsarago
Copy link
Member

closes #406

@vincentsarago vincentsarago changed the title Fix alpha band values when storing Uint16 data in **PNG** Fix alpha band values when storing Uint16 data in PNG Jul 29, 2021
@@ -344,6 +344,9 @@ def render(
if img_format == "WEBP" and data.shape[0] == 1:
data = numpy.repeat(data, 3, axis=0)

if img_format == "PNG" and data.dtype == "uint16" and mask is not None:
mask = linear_rescale(mask, (0, 255), (0, 65535)).astype("uint16")
Copy link
Member Author

@vincentsarago vincentsarago Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure we keep values in between 0 and 255 we apply a linear rescaling to 0 -> 65535

@vincentsarago vincentsarago merged commit 641d5a2 into master Jul 29, 2021
@vincentsarago vincentsarago deleted the Uint16AlphaBandValuesForPNG branch July 29, 2021 17:13
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.

[Render] Wrong values for PNG alpha band
2 participants