[gdal-dev] JPEG compressed COGs nodata

Frank Warmerdam warmerdam at pobox.com
Tue Jul 19 15:01:02 PDT 2022


Travis,

I am not aware of a good way to do this.   What I do is create separate
mask directories looking like te following.  Note the "Subfile Type:
transparency mask (4 = 0x4)" directories.  It isn't clear that all
applications will honor these, but modern GDAL treats this as a PER_DATASET
mask, and modern GDAL using applications that honor this style of masking
will support the mask properly.   I think modern QGIS does for instance,
and MapServer.   I could do some digging for the GDAL script code that
makes these if you like.

Best regards,
Frank


$ tiffinfo 20200708_082104_1002_Browse.tif
TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e)
encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482)
encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af)
encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34737 (0x87b1)
encountered.
TIFFReadDirectory: Warning, Unknown field with tag 42112 (0xa480)
encountered.
TIFF Directory at offset 0x17794e (1538382)
  Image Width: 5870 Image Length: 2889
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  ImageDescription: {"fp_center": [23.21221629852675, -19.107257323766635]}
  DateTime: 2020:07:08 08:21:04
  Tag 33550: 4.777314,4.777314,0.000000
  Tag 33922:
0.000000,0.000000,0.000000,2569932.323447,-2160669.364808,0.000000
  Tag 34735:
1,1,0,7,1024,0,1,1,1025,0,1,1,1026,34737,25,0,2049,34737,7,25,2054,0,1,9102,3072,0,1,3857,3076,0,1,9001
  Tag 34737: WGS 84 / Pseudo-Mercator|WGS 84|
  Tag 42112: <GDALMetadata>
  <Item name="DESCRIPTION" sample="0" role="description">red</Item>
  <Item name="DESCRIPTION" sample="1" role="description">green</Item>
  <Item name="DESCRIPTION" sample="2" role="description">blue</Item>
</GDALMetadata>

  JPEG Tables: (142 bytes)
TIFF Directory at offset 0xb6a (2922)
  Subfile Type: transparency mask (4 = 0x4)
  Image Width: 5870 Image Length: 2889
  Tile Width: 256 Tile Length: 256
  Bits/Sample: 1
  Sample Format: unsigned integer
  Compression Scheme: AdobeDeflate
  Photometric Interpretation: transparency mask
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Predictor: none 1 (0x1)
TIFF Directory at offset 0x14b8 (5304)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 1468 Image Length: 723
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (142 bytes)
TIFF Directory at offset 0x1888 (6280)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 734 Image Length: 362
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (142 bytes)
TIFF Directory at offset 0x1aa8 (6824)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 367 Image Length: 181
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  YCbCr Subsampling: 2, 2
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (142 bytes)
TIFF Directory at offset 0x1c68 (7272)
  Subfile Type: reduced-resolution image/transparency mask (5 = 0x5)
  Image Width: 1468 Image Length: 723
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 1
  Sample Format: unsigned integer
  Compression Scheme: AdobeDeflate
  Photometric Interpretation: transparency mask
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Predictor: none 1 (0x1)
TIFF Directory at offset 0x1f56 (8022)
  Subfile Type: reduced-resolution image/transparency mask (5 = 0x5)
  Image Width: 734 Image Length: 362
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 1
  Sample Format: unsigned integer
  Compression Scheme: AdobeDeflate
  Photometric Interpretation: transparency mask
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Predictor: none 1 (0x1)
TIFF Directory at offset 0x2094 (8340)
  Subfile Type: reduced-resolution image/transparency mask (5 = 0x5)
  Image Width: 367 Image Length: 181
  Tile Width: 128 Tile Length: 128
  Bits/Sample: 1
  Sample Format: unsigned integer
  Compression Scheme: AdobeDeflate
  Photometric Interpretation: transparency mask
  Samples/Pixel: 1
  Planar Configuration: single image plane
  Predictor: none 1 (0x1)

On Tue, Jul 19, 2022 at 3:19 PM Travis Kirstine <traviskirstine at gmail.com>
wrote:

> I've been trying to create a COG with JPEG compression with transparent
> nodata values without much success.  Is this possible without creating a
> secondary mask?
>
> Any hints?
>
> Regards
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>


-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | +1 650-701-7823
and watch the world go round - Rush    | Geospatial Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220719/74f54ca2/attachment.htm>


More information about the gdal-dev mailing list