[gdal-dev] ALPHA and PHOTOMETRIC options in TIFF

Even Rouault even.rouault at spatialys.com
Sat Jun 5 01:30:06 PDT 2021


Le 05/06/2021 à 10:24, Javier Jimenez Shaw a écrit :
> Hi
> I am struggling to save my data in (Geo)TIFF files with the proper 
> creation options.
> My data is not standard RGB(A), but a collection of bands like red, 
> green, (not necessarily blue), another type of red, near infrared, 
> etc, and Alpha. It can be uint8, uint16 or float.
> I was using PHOTOMETRIC=MINISBLACK and ALPHA=YES, but now I am not 
> sure if this is the proper configuration. In addition to that, I am 
> setting a ColorInterpretation to the bands (many bands as 
> GCI_Undefined, like for Near Infrared. The alpha band is clear as 
> GCI_AlphaBand).
This looks good. GDAL will potential write into its GDAL_METADATA XML 
tag custom band color interpretation if the very basic ones implied by 
only TIFF tags (Grey, Grey+Alpha, RGB, RGBA) don't fit your settings
> The "extra samples" is obscure to me, I do not know how many bands 
> expects, and how many are "extra". 
> (https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html 
> <https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html>)
You shouldn't worry too much about that tag. The GeoTIFF driver will 
take care of setting it. But basically if you use 
Photometric=MinIsBlack, then count(extra_samples) = number_bands - 1, or 
if you use Photometric=RGB, count(extra_samples) = number_bands - 3.
> TIFF says "There is no default for PhotometricInterpretation, and it 
> is required. Do not rely on applications defaulting to what you want." 
> in 
> https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html 
> <https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html>
> How should I create my TIFFs?

For what you describe, MinIsBlack is the appropriate Photometric value


My software is free, but my time generally not.

More information about the gdal-dev mailing list