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

gdal2tiles ignores alpha channel of the input #3953

Open
zdila opened this issue Jun 9, 2021 · 8 comments
Open

gdal2tiles ignores alpha channel of the input #3953

zdila opened this issue Jun 9, 2021 · 8 comments

Comments

@zdila
Copy link
Contributor

zdila commented Jun 9, 2021

Expected behavior and actual behavior.

I expect gdal2tiles to copy alpha-channel from the input tif (or vrt) to the output png files. It actually generates pngs where output alpha channel is always 100% for non-nodata pixels and 0% for nodata pixels. I would expect it to have alpha=0% for notada and alpha=value_from_alpha_channel for non-nodata pixels.

Steps to reproduce the problem.

My input file bands:

Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  NoData Value=255
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  NoData Value=255
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  NoData Value=255
Band 4 Block=256x256 Type=Byte, ColorInterp=Alpha
  NoData Value=255

Command for generating tiles:

gdal2tiles.py -r near -z 18 --xyz --processes=$(getconf _NPROCESSORS_ONLN) -n -w none input.tif tiles

Operating system

Linux 5.10.0-6-amd64 #1 SMP Debian 5.10.28-1 (2021-04-09) x86_64 GNU/Linux

GDAL version and provenance

3.2.1

@jratike80
Copy link
Collaborator

May be unrelated, but why do you have both NoData value and alpha?

@zdila
Copy link
Contributor Author

zdila commented Jun 9, 2021

May be unrelated, but why do you have both NoData value and alpha?

  • NoData - I have no data for those pixels (ie. unknown R, unknown G, unknown B, unknown A)
  • Alpha - I use this for transparency which is not just 0 or 255. (I am OK that I use 255 for NoData as in my data there will never be fully opaque pixels). For example I use value 127 for 50% transparency.

@jratike80
Copy link
Collaborator

jratike80 commented Jun 9, 2021

Ok. Developers will give you better answer, but as far as I know alpha for GDAL is often acting like a binary mask "zeros vs anything else than zero". For some other use case I would have a test by changing the interpretation of band 4 into undefined before processing and then back to alpha, but with thousands of tiles that is unpractical.

@zdila
Copy link
Contributor Author

zdila commented Jun 9, 2021

BTW I can generate png tiles with correct alpha using mapnik-based server (it is just more work to set it up). Also QGIS has no problem interpreting alpha channel correctly.

@rouault
Copy link
Member

rouault commented Jun 9, 2021

Please attach a small input file demonstrating the issue

@zdila
Copy link
Contributor Author

zdila commented Jun 9, 2021

Attached a sample.

sample.tif.gz

@fphilippe
Copy link

Hello everybody, i encounter the same issue. Any news ?

@TrimVis
Copy link

TrimVis commented Apr 11, 2024

I also experience the same issue. I assume there has been no progress on this?

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

5 participants