Correct way to read photometric interpretation?
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)?;
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 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!
That conversion is actually handled internally: https://github.com/image-rs/image-tiff/blob/96d3a02efe032f24175dacc614796fad48ec2772/src/decoder/image.rs#L661-L663
Huh! Thanks for taking the time to answer. I must be dealing with some other issue!