2011.11.30 13:58 "Re: [Tiff] Inconsistent metadata report for CMYK 8-bit image", by Even Rouault
#################################################################### 2) gdalinfo (from current OSGeo4W package)
C:\> gdalinfo Shadow_cmyk8.tif
Warning 1: TIFFReadDirectory:Unknown field with tag 37724 (0x935c) encountered Driver: GTiff/GeoTIFF
Files: Shadow_cmyk8.tif
Size is 768, 505
Coordinate System is `'
Metadata:
TIFFTAG_SOFTWARE=Adobe Photoshop CS3 Windows
TIFFTAG_DATETIME=2011:10:31 14:09:04
TIFFTAG_XRESOLUTION=72
TIFFTAG_YRESOLUTION=72
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Image Structure Metadata:
SOURCE_COLOR_SPACE=CMYK
INTERLEAVE=PIXEL
Corner Coordinates:Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 505.0)
Upper Right ( 768.0, 0.0)
Lower Right ( 768.0, 505.0)
Center ( 384.0, 252.5)
Band 1 Block=768x2 Type=Byte, ColorInterp=RedMask Flags: PER_DATASET ALPHA
Band 2 Block=768x2 Type=Byte, ColorInterp=Green
Mask Flags: PER_DATASET ALPHA
Band 3 Block=768x2 Type=Byte, ColorInterp=Blue
Mask Flags: PER_DATASET ALPHA
Band 4 Block=768x2 Type=Byte, ColorInterp=Alpha
Which one is right?
How many bits per sample and how many samples per pixel is there?
By default, with unusual color spaces like CMYK, GDAL will go through the libtiff RGBA API that does the colorspaces conversions and expose a regular RGBA dataset to GDAL.
You can try however: gdalinfo GTIFF_RAW:Shadow_cmyk8.tif
and with latest trunk (and likely 1.8 too), you'll see:
C:\gdal_trunk\gdal>gdalinfo GTIFF_RAW:Shadow_cmyk8.tif
Driver: GTiff/GeoTIFF
Files: Shadow_cmyk8.tif
Size is 768, 505
Coordinate System is `'
Metadata:
TIFFTAG_DATETIME=2011:10:31 14:09:04
TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
TIFFTAG_SOFTWARE=Adobe Photoshop CS3 Windows
TIFFTAG_XRESOLUTION=72
TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 0.0, 0.0)
Lower Left ( 0.0, 505.0)
Upper Right ( 768.0, 0.0)
Lower Right ( 768.0, 505.0)
Center ( 384.0, 252.5)
Band 1 Block=768x2 Type=Byte, ColorInterp=Cyan
Band 2 Block=768x2 Type=Byte, ColorInterp=Magenta
Band 3 Block=768x2 Type=Byte, ColorInterp=Yellow
Band 4 Block=768x2 Type=Byte, ColorInterp=Black
Band 5 Block=768x2 Type=Byte, ColorInterp=Black
Note the wrong color interpretation was wrong for the last band. The code assumed that for CMYK, you have only 4 bands. I've just fixed that in trunk, and now it reports alpha for band 5.