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

Support writing ASCII array in TIFF metadata #656

Merged
merged 2 commits into from
Jan 12, 2022

Conversation

Schmidor
Copy link
Contributor

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.

Copy link
Owner

@haraldk haraldk left a 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! 😀

Comment on lines 426 to 428
byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
stream.write(bytes);
stream.write(0);
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Owner

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.

@haraldk haraldk merged commit 74611e4 into haraldk:master Jan 12, 2022
haraldk added a commit that referenced this pull request Jan 12, 2022
haraldk pushed a commit that referenced this pull request Feb 21, 2022
* Support writing ASCII array in TIFF metadata

* corrected formatting and extracted string writing to method

(cherry picked from commit 74611e4)
haraldk added a commit that referenced this pull request Feb 21, 2022
(cherry picked from commit eced5b8)
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

Successfully merging this pull request may close these issues.

None yet

2 participants