On samedi 30 septembre 2017 21:01:57 CEST Rahkonen Jukka (MML) wrote: > Hi, > > I have been searching an easy way to change the interpretion of 4-channel > images between RGBA and RGB+undefined. Wouldn't if be useful to make > gdal_edit to support also changing the TIFFTAG_EXTRASAMPLES metadata? Or do > we have some other easy way for performing that task?
Jukka, I couldn't find a clean working way. I had though that calling ds.GetRasterBand(4).SetColorInterpretation(gdal.GCI_AlphaBand or gdal.GCI_Undefined) would work (which could have been done by a new option of gdal_edit to modify the color interpretation). But for some (not clear, and likely unneeded) reason, this is restricted on a fresh new file, not yet "crystalized" (if you do it on an existing file, the change will only go to the .aux.xml file). I don't see a strong reason for this restriction, so it could probably be removed. I've also tried the tiffset utility, but for some reason it absolutely wants to set at least 2 values in the ExtraSamples tag. Sounds like a bug of tiffset/libtiff So to set alpha: tiffset -s 338 2 2 0 test.tif 338 = code for ExtraSamples 2 = 2 values 2 = alpha unassociated 0 = undefined (ignored, and somehow invalid since that sample doesn't exist) (should normally be tiffset -s 338 1 2 test.tif if that worked properly) or to set undefined tiffset -s 338 2 0 0 test.tif (should normally be tiffset -s 338 1 0 test.tif if that worked properly) GDAL will be happy, but technically the TIFF is not so correct with that 2nd extra sample, since for a Photometric=RGB with 4 samples, you should just have 1 extra sample. I would also have suggested to just take your favorite hexadecimal editor, and just alter the proper byte, but I don't feel this will be a popular option ;-) Even -- Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev
