Jonathan Behrens
Jonathan Behrens
Unfortunately, I think this is another consequence of DynamicImage implementing the GenericImage trait. See also: #2237, #2274, and #2344
The relevant code is in https://github.com/image-rs/image/blob/main/src/codecs/pnm/encoder.rs The easiest thing might be to either step through it with a debugger or add some println! calls to see which code path is...
Short answer is that `write_image` internally calls `directory.finish()` so you shouldn't call it yourself. The dimensions also get set in `write_image` though I think it is harmless to set them...
I don't have time to look into this right now, but this is how the `image` crate uses the TiffEncoder: https://github.com/image-rs/image/blob/d48c6a6ff310b356018ffd6b5daff0d73587c039/src/codecs/tiff.rs#L342
I think it is a matter of rebasing and then doing a full read-through of the TGA decoder to double check that the rest of the code isn't making assumptions...
I think `Option` is generally preferable for `try_` methods that have only one failure mode. We should certainly add the "panics" section to the docs on the `view` method, but...
Could you share a failing image? Is it possible there's an embedded ICC profile and we have a [longstanding issue to handle those better ](https://github.com/image-rs/image/issues/786)
We have the low level capability [to read ICC profiles](https://docs.rs/image/latest/image/trait.ImageDecoder.html#method.icc_profile), but aren't yet able to write them when encoding images
https://github.com/image-rs/image/pull/2322 just added support for writing ICC profiles when producing WebP images.
Actually, I wonder if we should create a new `metadata` module for the `Orientation` enum. It would be a natural place if we end up adding other types from https://github.com/image-rs/image/issues/2222