-
Notifications
You must be signed in to change notification settings - Fork 17
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 parsing auxiliary images #297
Conversation
these are only meaningful in HeifImage class
After this line pillow_heif/pillow_heif/misc.py Line 480 in b4b5d64
should be added self.aux_image_ids: list = [] at least for tests to start and not fail on the first one |
second: GitHub was right, please return that step is need to copy as I understand we do not need any additional metadata for AUX the images so in third: please add some tests for aux images. It will be nice to have coverage for all code except in general it looks fine to me such implementation. |
Thanks for the review. I'll make those changes later today or tomorrow. I wanted to get your opinion on a slightly different way of representing this auxiliary info. From a usage perspective, people will likely have an aux-type in mind to access. So with what I proposed above, they'll have to iterate through all the aux IDs and check for that aux-type. How about having So I can do: aux_type = "urn:com:apple:photo:2020:aux:hdrgainmap"
assert aux_type in heif_image.info["aux"]
aux_id = heif_image.info["aux"][aux_type][0]
hdrgainmap = heif_image.get_aux_image(aux_id) instead of something like: aux_type = "urn:com:apple:photo:2020:aux:hdrgainmap"
aux_ids = [aux_id for aux_id, metadata in heif_image.info["aux"].items()
if metadata["type"] == aux_type]
assert len(aux_ids) > 0
hdrgainmap = heif_image.get_aux_image(aux_ids[0]) What do you think? Side note: Please take a look at #298 too |
Personally, I am satisfied with both methods, but I am more interested in how I can get these aux images when using Pillow? |
You're right! That was a mistake on my end. I had misunderstood the code when I made that change.
True,
I'll add tests soon, and I have a sample heic image that I took on my iphone (having hdrgainmap) and cropped so the size is ~230KB. Shall I simply add it to the repo at
Right now, only registering a pillow load hook will not be enough to access AUX images since they're not available directly from
The reason I avoided loading AUX images during the initialization of |
No, repo does not use Git LFS. And yes, just add the file to the
what you said makes sense, since it's a feature in the beta version, it doesn't have to be implemented for the pillow_plugin. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #297 +/- ##
===========================================
- Coverage 100.00% 99.89% -0.11%
===========================================
Files 10 10
Lines 956 976 +20
===========================================
+ Hits 956 975 +19
- Misses 0 1 +1
|
One of the images in the repo already had hdrgainmap aux image. So I just used it in the new test. |
As far as I understand, the PR is ready? If it is not too much trouble, could you also modify this test: pillow_heif/tests/options_test.py Line 27 in ba64851
In theory, three lines should be added there, just like with DEPTH_IMAGES |
Yes
Done! |
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 a lot for the great PR, the release will most likely be at the end of the week.
Fixes (partially) #117 .
Changes proposed in this pull request:
aux_image_ids
toCtxImage
that returns a list of non-depth non-alpha auxiliary image IDs.get_aux_type(aux_id)
toCtxImage
that returns a string representing theaux_type
of the givenaux_id
.aux
toHeifImage.info
dict which is also a dict mapping fromaux_type
strings to a list ofaux_id
s.get_aux_image(aux_id)
toCtxImage
that returns aCtxImage
corresponding to the givenaux_id
.get_aux_image(aux_id)
toHeifImage
which returns an instance of a new classHeifAuxImage
wrapping the aboveCtxImage
, after ensuring that the auxiliary image is 8-bit monochrome.get_aux_image(aux_id)
toHeifFile
which calls the same method of the primary image.