Hi,

I believe that what you want happens automatically.  I made some tests with 
GDAL version 3.13.0dev-a4cba2aeca, released 2026/02/04 and command

gdal_translate -f gpkg -b 1 p4433h.tif 1band.gpkg -co tile_format=png

gdalinfo reports only one band

Band 1 Block=256x256 Type=Byte, ColorInterp=Gray

I exported couple of the png blobs from the gpkg with spatialite-gui, and the 
full png tiles seem to have single band, but the border tiles which contain 
nodata area have also alpha band.

The tile tables in geopackage can contain a mixture of different image blobs, 
for example single band png tiles and single band + alpha png tiles. Reporting 
the exact band type for such mixture is not possible. GDAL has some rules and 
options for handling the case, see 
https://gdal.org/en/stable/drivers/raster/gpkg.html#raster-gpkg-tile-formats 
and open option "band_count".

Probably everything works fine and GDAL saves the tiles automatically so that 
no disk space is wasted. If you need to to be sure, study the blobs directly 
and check what bit depth and color type they really have.

-Jukka Rahkonen-
________________________________________
Lähettäjä: gdal-dev <[email protected]> käyttäjän Philippe 
Ghesquiere via gdal-dev <[email protected]> puolesta
Lähetetty: Maanantai 16. helmikuuta 2026 8.41
Vastaanottaja: gdal-dev <[email protected]>
Aihe: [gdal-dev] GPKG : how to save tile into 1-band 8-bit PNG

Dear all,Some contextIn our system, we convert elevation data into Geopackage 
in order to use them with mapcache/mapserver.For our display needs, we save two 
layers in a GPKG file :a color-relief layer  : saved as RGBA 8-bit PNG tilesa 
hillshade layer : saved as RGBA 8-bit PNG tilesMy environmentGDAL V3.8.4My 
question :Since a hillshade image is a gray-scale image, isn't it possible to 
save tiles in 1-band 8-bit PNG + Alpha band, instead of RGB, into a PKG 
database?I have tried several options with either gda_translate (-b 1, -ot 
Byte, TILE_FORMAT=PNG or PNG8)  or gdalwarp, with no success.Thanks for any 
hints you could give me.SincerelyPhilippeThe information in this e-mail is 
confidential. The contents may not be disclosed or used by anyone other than 
the addressee. Access to this e-mail by anyone else is unauthorised.If you are 
not the intended recipient, please notify Airbus immediately and delete this 
e-mail.Airbus cannot accept any responsibility for the accuracy or completeness 
of this e-mail as it has been sent over public networks. If you have any 
concerns over the content of this message or its Accuracy or Integrity, please 
contact Airbus immediately.All outgoing e-mails from Airbus are checked using 
regularly updated virus scanning software but you should take whatever measures 
you deem to be appropriate to ensure that this message and any attachments are 
virus free.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to