Skip to content

feat(geotiff): Add colorinterp property - #317

Merged
kylebarron merged 7 commits into
mainfrom
kyle/colorinterp
Jul 10, 2026
Merged

kylebarron merged 7 commits into
mainfrom
kyle/colorinterp

Conversation

@kylebarron

@kylebarron kylebarron commented Mar 5, 2026 •

Copy link
Copy Markdown
Member

@kylebarron
kylebarron enabled auto-merge (squash) July 10, 2026 18:32
@kylebarron
kylebarron merged commit cefbb96 into main Jul 10, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/colorinterp branch July 10, 2026 18:34
@kylebarron kylebarron self-assigned this Jul 10, 2026
kylebarron added a commit that referenced this pull request Oct 16, 2026
…unt (#732)

> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

The default COG pipeline drew the fourth band of any 4-band RGB image as
alpha. NAIP's fourth band is near-infrared (ExtraSamples 0,
"unspecified"), so water and shadows, which reflect little
near-infrared, were drawn see-through. A gray+alpha image lost its alpha
instead: its two-channel texture samples the alpha band into `color.g`,
and `BlackIsZero` or `WhiteIsZero` then writes the gray value over it.

The pipeline now decides from the bands' color interpretation (#317):

- An RGB image whose fourth band isn't alpha is drawn opaque, with a new
`Opaque` module.
- A gray image whose second band is alpha gets a new `GrayAlpha` module,
which moves that band into alpha before the gray-to-RGB module runs.
- RGBA images, and gray images whose second band isn't alpha, are drawn
as before.

Both modules are exported from
`@developmentseed/deck.gl-raster/gpu-modules`, next to `BlackIsZero` and
the other color modules.

`colorInterp` now counts associated (premultiplied) alpha as alpha, as
GDAL does; it counted only unassociated alpha. Without this, the
pipeline would have drawn associated-alpha images opaque. Their color is
still not un-premultiplied, as before. `ColorInterp` is now exported
from `@developmentseed/geotiff`, since the public `colorInterp` getter
returns it.

Checked in Chrome with cog-basic, temporarily pointed at a 4-band NAIP
COG and at a gray+alpha COG whose left half has alpha 0. Before, the
NAIP reservoir showed the basemap's water through the image and the gray
image's transparent half was drawn; after, the reservoir is opaque and
that half is transparent. The 3-band NAIP COG already in cog-basic
renders pixel-identical before and after.

Closes #187, closes #361

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotiff: Implement colorinterp attribute on GeoTIFF

1 participant