COGLayer draws 4-band CMYK COGs as RGBA, skipping CMYKToRGB

Open
#857 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start in packages/deck.gl-geotiff/src/geotiff/render-pipeline.ts, especially photometricInterpretationToRGB and its CMYKToRGB, cieLabToRGB, and Ycbcr cases. First check what the JPEG decoding path returns for CMYK, then find or create CMYK and CIELab fixtures; the issue names GDAL creation options. Done means selecting conversions by photometric interpretation and testing that CMYK and CIELab render correctly without double converting JPEG data.

Written by the indexing model from the issue text.

Description

bug cog

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

COGLayer's default pipeline draws a 4-band CMYK COG as if its bands were red, green, blue and alpha, so its colors are wrong.

Cause

photometricInterpretationToRGB returns no color conversion for any 3- or 4-band image before it looks at the photometric interpretation (render-pipeline.ts#L307-L310):

if (count === 3 || count === 4) {
  // Always interpret 3-band or 4-band images as RGB/RGBA
  return null;
}

So the CMYKToRGB case for Photometric.Separated (L356-L360) never runs for a 4-band image. The same check skips the cieLabToRGB case (L366-L369) for a 3-band CIELab image.

This predates 0.10.

Fix

Choose the conversion by photometric interpretation first, and keep the band-count check only for the interpretations that need no conversion.

Before changing it:

  • JPEG compression. @developmentseed/geotiff decodes JPEG tiles through the browser's image decoder, which already converts YCbCr to RGB (the Ycbcr case relies on that). Check what that path returns for a JPEG-compressed CMYK file, which a browser may also convert, so CMYKToRGB would run twice.
  • Fixtures. geotiff-test-data has no CMYK or CIELab file, so a test needs one. GDAL writes CMYK with -co PHOTOMETRIC=CMYK and CIELab with -co PHOTOMETRIC=CIELAB.

🤖 Written by Claude Code

Dominant language
TypeScript
Stars
240
Forks
34
Avg merge
17h 24m
Merged PRs (30d)
62

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/deck.gl-raster

All issues in developmentseed/deck.gl-raster

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.