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

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

Open
REASY opened this issue Jul 9, 2023 · 0 comments

Comments

@REASY
Copy link

REASY commented Jul 9, 2023

WebImageDecoder should take into consideration fileDirectory.SamplesPerPixel. If it is equal to 3 it must convert buffer from RGB to RGBA.

RGB example, file webp_rgb.tif

The output of gdalinfo on attached webp_rgb.tif (webp.zip)

Data axis to CRS axis mapping: 1,2
Origin = (-13044819.684176461771131,3859305.558118546847254)
Pixel Size = (0.074645535434684,-0.074645535434684)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=WEBP
  INTERLEAVE=PIXEL
  LAYOUT=COG
Corner Coordinates:
Upper Left  (-13044819.684, 3859305.558) (117d11' 0.99"W, 32d43'42.15"N)
Lower Left  (-13044819.684, 3859229.121) (117d11' 0.99"W, 32d43'40.07"N)
Upper Right (-13044743.247, 3859305.558) (117d10'58.52"W, 32d43'42.15"N)
Lower Right (-13044743.247, 3859229.121) (117d10'58.52"W, 32d43'40.07"N)
Center      (-13044781.466, 3859267.340) (117d10'59.76"W, 32d43'41.11"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4

When I try to render it (using cog-explorer running locally):
image

RGBA example, file webp_rgba.tif

The output of gdalinfo on attached webp_rgba.tif (webp.zip)

Data axis to CRS axis mapping: 1,2
Origin = (-13044819.684176461771131,3859305.558118546847254)
Pixel Size = (0.074645535434684,-0.074645535434684)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=WEBP
  INTERLEAVE=PIXEL
  LAYOUT=COG
Corner Coordinates:
Upper Left  (-13044819.684, 3859305.558) (117d11' 0.99"W, 32d43'42.15"N)
Lower Left  (-13044819.684, 3859229.121) (117d11' 0.99"W, 32d43'40.07"N)
Upper Right (-13044743.247, 3859305.558) (117d10'58.52"W, 32d43'42.15"N)
Lower Right (-13044743.247, 3859229.121) (117d10'58.52"W, 32d43'40.07"N)
Center      (-13044781.466, 3859267.340) (117d10'59.76"W, 32d43'41.11"N)
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4
Band 4 Block=512x512 Type=Byte, ColorInterp=Alpha
  NoData Value=0
  Overviews: 256x256, 128x128, 64x64, 32x32, 16x16, 8x8, 4x4

When I try to render it (using cog-explorer running locally), it looks fine :
image

// 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

Environment

  • Google Chrome 114.0.5735.198 (Official Build) (64-bit)
  • geotiff 2.0.7

Attached two GeoTIFF files as an example
webp.zip

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

No branches or pull requests

1 participant