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

Private fields and interfaces make file inspection difficult #222

Open
jblachly opened this issue Feb 2, 2024 · 3 comments
Open

Private fields and interfaces make file inspection difficult #222

jblachly opened this issue Feb 2, 2024 · 3 comments

Comments

@jblachly
Copy link

jblachly commented Feb 2, 2024

My use case is relatively simple:

I need to look for images (within the IFD of a given file) with a particular (Tag, Value) pair and remove them.

Zooming out, it would be nice if the API supported such a use case relatively directly (for example, streaming images from a Decoder to Encoder , potentially with a filter).

Still, implementing this by hand looks to be difficult to impossible, because:

  1. No way to know how many IFDs are present (I understand this is a design decision to support streaming decoding)
  2. Image is pub(crate), meaning I cannot iterate a list of tags. Alternatively, a member function to provide Directory would be helpful.

Am I approaching this wrongly? Thanks in advance for thoughts or advice.

@fintelia
Copy link
Contributor

fintelia commented Feb 3, 2024

Yeah, the crate doesn't really expose an interface for editing existing TIFF files at the moment. You can use get_tag and more_images / next_image to determine which images have the specific tag, but there isn't a way to request all the other tags to encode a new TIFF with everything but that one tag

@jblachly
Copy link
Author

jblachly commented Feb 5, 2024

Yeah, the crate doesn't really expose an interface for editing existing TIFF files at the moment. You can use get_tag and more_images / next_image to determine which images have the specific tag, but there isn't a way to request all the other tags to encode a new TIFF with everything but that one tag

Given the way the library is structured with Decoder and Encoder, I get the idea that modifying existing file is out of scope, and that seems fine to me.

My real issue is that even duplicating a file with paired Decoder/Encoder seems impossible given that the set of tags is un-knowable.

Would it make sense to make fully pub (not just pub(crate)) decoder::Image? Or, at a minimum to have a method on Decoder that returns ifd: Option<Directory>?

I can make some of these changes but would be ideal if I design it for future upstreamability

@fintelia
Copy link
Contributor

fintelia commented Feb 11, 2024

Exposing the Option<&Directory> would probably be the way to go. The type is already public so it would just be a matter of adding the method. I've been wanting to do a more complete overhaul of the crate API for a long time, but it is kind of a lot of work and I haven't gotten around to it...

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