image-tiff icon indicating copy to clipboard operation
image-tiff copied to clipboard

Correct way to read photometric interpretation?

Open aconbere opened this issue 1 year ago • 4 comments

What's the intended way to access the photometric interpretation tag? By the time I have a decoder it's been parsed and stored in the Image. But the image field is private and the Decoder doesn't offer a method to access it. Should I just fall back on munging about with tags?

        let photometric_interpretation = tag_reader
            .find_tag(Tag::PhotometricInterpretation)?
            .map(Value::into_u16)
            .transpose()?
            .and_then(PhotometricInterpretation::from_u16)
            .ok_or(TiffUnsupportedError::UnknownInterpretation)?;

aconbere avatar Nov 15 '24 16:11 aconbere

That's probably the best way to get the photometric interpretation at the moment. There's also the option of calling Decoder::colortype to get a processed version.

fintelia avatar Nov 15 '24 21:11 fintelia

@fintelia Ah yeah so I'm already using colortype, in this case I have two tiffs with the same colortype but flipped if zero is black or white is black which isn't encoded into the colortype. Thank you!

aconbere avatar Nov 19 '24 23:11 aconbere

That conversion is actually handled internally: https://github.com/image-rs/image-tiff/blob/96d3a02efe032f24175dacc614796fad48ec2772/src/decoder/image.rs#L661-L663

fintelia avatar Nov 20 '24 00:11 fintelia

Huh! Thanks for taking the time to answer. I must be dealing with some other issue!

aconbere avatar Nov 20 '24 05:11 aconbere