image-rs / jpeg-decoder

JPEG decoder written in Rust
Apache License 2.0
150 stars 87 forks source link

Provide ability to override colour transform? #238

Closed AlanRace closed 1 year ago

AlanRace commented 2 years ago

Decompressing JPEG encoded .tiff files causes incorrect colour conversion (e.g. https://github.com/image-rs/image-tiff/issues/124). This has been temporarily resolved by modifying the JPEG header before being passed to jpeg-decoder (see https://github.com/image-rs/image-tiff/pull/148). This is not an ideal solution and feels somewhat hacky.

As the tiff header includes information on the PhotometricInterpretation and necessary parameters for colour conversion, my ideal solution would be to provide an option to ensure that jpeg-decoder doesn't do any form of colour correction/conversion and simply passes back the decompressed data, so that this can be handled by the image-tiff library (https://github.com/image-rs/image-tiff). Does that sound reasonable? If so I can propose a PR.

HeroicKatora commented 2 years ago

The approach sounds good, in particular ensuring that Upsampler::upsample_and_interleave_row is passed a no-op for its color_convert, and a PR would be great.