-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Support writing ASCII array in TIFF metadata #656
Conversation
a839cca
to
2f2af5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍🏻
I wasn't aware of this multiple string thing when I originally wrote it, thus the issue here... Perhaps a more efficient way would be to convert the strings to byte array right away? But I think this is fine for now.
I had some minor comments, will merge if you address those! 😀
byte[] bytes = string.getBytes(StandardCharsets.UTF_8); | ||
stream.write(bytes); | ||
stream.write(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps extract this (and the code below for single string) to a writeString(stream, string)
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've extracted the duplicate code. But i'm not sure what could be changed for a more efficient converting to bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about perhaps storing the byte[]
instead of String/String[]
in the TIFFEntry
. Instead of converting the Strings to bytes twice, once for the value count, and once for the actual write...
But I don't think this is used enough to warrant that refactoring just now. I'm fine with the current solution.
imageio/imageio-metadata/src/main/java/com/twelvemonkeys/imageio/metadata/tiff/TIFFWriter.java
Outdated
Show resolved
Hide resolved
* Support writing ASCII array in TIFF metadata * corrected formatting and extracted string writing to method (cherry picked from commit 74611e4)
(cherry picked from commit eced5b8)
Currently the TIFF reader supports reading fields which contain multiple ASCII strings. Writing those metadata again then fails, because writing ASCII string arrays is not supported.