Skip to content

Conversation

rgov
Copy link

@rgov rgov commented Jun 30, 2025

The WebImageDecoder always returns a buffer of RGBA pixel values. If the caller is expecting RGB, a corrupted image is rendered. There was a TODO comment remarking on this:

// TODO: check how many samples per pixel we have, and return RGB/RGBA accordingly
// it seems like GDAL always encodes via RGBA which does not require a translation

This resolves the issue by removing the alpha channel if SamplesPerPixel is 3.

Fixes #373.

Before and after (disregard the overlay text):
before after

Copy link
Collaborator

@TheMrCam TheMrCam left a comment

Choose a reason for hiding this comment

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

LGTM 👍 I actually encountered this for the first time recently—appreciate the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: GeoTIFF compressed with WEBP with 3 channels R, G and B is rendered incorrectly
2 participants