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

Add basic support for .heic files #519

Merged
merged 6 commits into from
Dec 16, 2024
Merged

Add basic support for .heic files #519

merged 6 commits into from
Dec 16, 2024

Conversation

ususdei
Copy link
Contributor

@ususdei ususdei commented May 26, 2024

No description provided.

Copy link
Owner

@saimn saimn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry about the delay. The PR looks good but it will need a rebase. Also would be great if you can add a test and test image (with an open source license).

if hasattr(img, "_getexif") and callable(img._getexif):
exif = img._getexif()
elif "exif" in img.info:
exif = img.getexif()._get_merged_dict()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

img._getexif() is an alias for img.getexif()._get_merged_dict() so we can probably switch to the public methods, which I think are supported since a long time ? (Our min version of pillow is 8.0 currently)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gladly!
I just wasn't sure if I would break any weird combination, because both variants use some private API.
But let tox find out :-)

@@ -264,7 +264,7 @@ def exif(self):
datetime_format = self.settings["datetime_format"]
return (
get_exif_tags(self.raw_exif, datetime_format=datetime_format)
if self.raw_exif and self.src_ext in (".jpg", ".jpeg")
if self.raw_exif and self.src_ext in (".jpg", ".jpeg", ".heic")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension list here and below should also include ".heif" I guess ?
Also, those extensions should be recognized only if pillow-heif is available, so might be better to store this list somewhere where it can be imported (in the image module ?) and reused.

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'm not sure about .heif files. As I understand it, this is more of a container format and may contain different image-formats.
I guess pillow-heif should be able to handle them all, but I have no way to test that yet.

I would actually prefer it if the program errors out if it encounters .heic images without pillow-heif installed, instead of just silently ignoring and skipping those pictures.
I mean, they are in fact Images - no matter if supported or not - and the user probably intended for them to be included in the gallery.

Copy link

codecov bot commented Nov 2, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.57%. Comparing base (5752eca) to head (536f658).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/sigal/image.py 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #519      +/-   ##
==========================================
- Coverage   90.72%   90.57%   -0.15%     
==========================================
  Files          24       24              
  Lines        2026     2037      +11     
==========================================
+ Hits         1838     1845       +7     
- Misses        188      192       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@saimn saimn added this to the 2.5 milestone Dec 9, 2024
@saimn
Copy link
Owner

saimn commented Dec 9, 2024

@ususdei - I played a bit with the code and activated .heic extensions by default so sigal finds them and logs a warning if pillow-heif is missing. Is it ok for you ? And just to be sure, test image is one of yours that you accept to share under sigal's license ?

@ususdei
Copy link
Contributor Author

ususdei commented Dec 14, 2024

@saimn Yeah, sure! I'm totally okay with that. And thanks for the cleanup.

I took that random picture specifically for that purpose.
So just to give that explicitly in writing: I am the author of the photo in tests/sample/pictures/dir1/test1/outdoor.heic and hereby release it into public domain or alternatively under the MIT license.

@saimn
Copy link
Owner

saimn commented Dec 16, 2024

Great, thanks a lot !

@saimn saimn merged commit 5352699 into saimn:main Dec 16, 2024
7 of 9 checks passed
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.

2 participants