Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct way to read photometric interpretation? #254

Open
aconbere opened this issue Nov 15, 2024 · 4 comments
Open

Correct way to read photometric interpretation? #254

aconbere opened this issue Nov 15, 2024 · 4 comments

Comments

@aconbere
Copy link

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)?;
@fintelia
Copy link
Contributor

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.

@aconbere
Copy link
Author

@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!

@fintelia
Copy link
Contributor

That conversion is actually handled internally:

if photometric_interpretation == PhotometricInterpretation::WhiteIsZero {
super::invert_colors(tile, color_type, self.sample_format);
}

@aconbere
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants