-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add support for variable length custom tags #173
Merged
djhoese
merged 1 commit into
pearu:master
from
delmic:ctypes-suport-adding-custom-tags-vlen
Jan 16, 2024
Merged
Add support for variable length custom tags #173
djhoese
merged 1 commit into
pearu:master
from
delmic:ctypes-suport-adding-custom-tags-vlen
Jan 16, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 7534177906
💛 - Coveralls |
djhoese
reviewed
Jan 12, 2024
djhoese
reviewed
Jan 12, 2024
pieleric
force-pushed
the
ctypes-suport-adding-custom-tags-vlen
branch
from
January 14, 2024 00:48
363f5ec
to
a3a8bbc
Compare
pearu
requested changes
Jan 14, 2024
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 have a couple of minor nits but overall looks good to me. Thanks!
pieleric
force-pushed
the
ctypes-suport-adding-custom-tags-vlen
branch
from
January 14, 2024 23:31
a3a8bbc
to
4cb287b
Compare
pearu
reviewed
Jan 15, 2024
pieleric
force-pushed
the
ctypes-suport-adding-custom-tags-vlen
branch
2 times, most recently
from
January 15, 2024 17:04
10ff716
to
d1b67d1
Compare
In libtiff, custom tags with variable length (eg, a binary blob) are indicated with the special constants TIFF_VARIABLE (-1) or TIFF_VARIABLE2 (-3). In such case, when reading a field the length is passed as first argument, and the data as a pointer as second argument. So far, some standard tags with such format were supported, but not custom tags. => Add support for such tags. Also fix the names of the attribute created automatically, which got broken in the switch from Python 2 to 3. What should have been named, for instance, TIFFTAG_CUSTOM, was named like TIFFTAG_b'CUSTOM', quotes included! Also fix the test cases, which were not working, mostly related to reading/writing tags.
pieleric
force-pushed
the
ctypes-suport-adding-custom-tags-vlen
branch
from
January 15, 2024 21:30
d1b67d1
to
8fdf307
Compare
pearu
approved these changes
Jan 16, 2024
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.
LGTM! Thanks, @pieleric!
djhoese
approved these changes
Jan 16, 2024
djhoese
changed the title
ctypes: support adding custom tags with variable length
Add support for variable length custom tags
Jan 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In libtiff, custom tags with variable length (eg, a binary blob) are indicated with the special constants
TIFF_VARIABLE
(-1) orTIFF_VARIABLE2
(-3). In such case, when reading a field, the length is passed as first argument, and a pointer to the data as second argument.So far, some standard tags with such format were supported, but not custom tags. We needed such tags to support reading metadata from some microscopes. We had to hack it by modifying directly
tifftags
. You can see it here:https://github.com/delmic/odemis/blob/a025bc7d991a37b408adb031a2561c35c3b87d23/src/odemis/dataio/tiff.py#L95
This change allows to directly extend the custom tags, with
add_tags()
.Also fix the names of the automatically created attribute, which got broken in the switch from Python 2 to 3.
What should have been named, for instance,
TIFFTAG_CUSTOM
, was named likeTIFFTAG_b'CUSTOM'
, quotes included!Also fix the test cases, which were not working, mostly related to reading/writing tags.
Now, all the tests pass, as run with:
python3 ./libtiff/libtiff_ctypes.py