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 HEIF image file #1042

Merged
merged 11 commits into from
Oct 31, 2023
Merged

Support HEIF image file #1042

merged 11 commits into from
Oct 31, 2023

Conversation

Pandede
Copy link
Contributor

@Pandede Pandede commented Sep 30, 2023

Resolves #1021.
The previous pull request #1040 is closed as the redundant commits.
And also, move pillow-heif to be a plugin rather than extra requirement of Pillow (thanks for the advice of @bigcat88).

@bigcat88
Copy link

never mind about my previous deleted comment.

as I see, CI needs wheels for PyPy3.8 - if I will know that this will have high chances to be merged, I can restore the publishing of PyPy3.8 wheels for the next release, if it is needed.

Copy link
Contributor

@FirefoxMetzger FirefoxMetzger left a comment

Choose a reason for hiding this comment

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

Awesome initiative, thanks @Pandede 🚀 This looks pretty good from the plugin implementation side. I think we'll only need one round of reviews before we can merge.

We should properly register the format so that pillow is automatically tried first for .heic files. To do so we need to add a new FileExtension in the relevant config file. This will also add the necessary documentation so that HEIC shows up in the list of supported formats :)

Beyond that, there is one change (making pillow_heif option) that I would like to see before we merge.

imageio/plugins/pillow.py Outdated Show resolved Hide resolved
imageio/plugins/pillow.py Outdated Show resolved Hide resolved
tests/test_pillow.py Outdated Show resolved Hide resolved
@bigcat88
Copy link

as I see, CI needs wheels for PyPy3.8 - if I will know that this will have high chances to be merged, I can restore the publishing of PyPy3.8 wheels for the next release, if it is needed.

done from my side, new release was published :)

@Pandede
Copy link
Contributor Author

Pandede commented Oct 16, 2023

The tests are failed as the latest upgrade of Pillow. All tests passed if Pillow==10.0.1 but failed if Pillow==10.1.0.

Update:
I just go through the patch note of Pillow==10.1.0, directly open an image with custom mode is no longer available:

# Raise AttributeError
image = Image.open("example.png", mode="L")
# Should specify the mode by using `convert`
image = Image.open("example.png").convert("L")

Here is the reference.

@FirefoxMetzger
Copy link
Contributor

FirefoxMetzger commented Oct 18, 2023

Yes. There is another issue related to pillow's recent upgrade. I'll pin pillow for now.

Copy link
Contributor

@FirefoxMetzger FirefoxMetzger left a comment

Choose a reason for hiding this comment

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

Looks good from my side.

I will check why why the pypi CI no longer likes the av package and then we should be able to get a green CI :)

@FirefoxMetzger FirefoxMetzger merged commit 6cd3e2d into imageio:master Oct 31, 2023
21 checks passed
@@ -1855,6 +1855,9 @@ def reset(self):
extension=".btf",
priority=["tifffile"],
),
FileExtension(
name="High Efficiency Image File Format", extension=".heic", priority=["pillow"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shoudn't ".heif" and ".hif" (and potentially ".avif") be added as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kmilos Looks like @Pandede is one step ahead: #1048

AVIF support is already merged :) as for HIF I'm not sure. Is it just a different suffix for HEIF but actually the same format?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Some cameras now output .HIF directly (I guess limitations of sdcard filesystem like old 8.3 filename format from DOS times!)

Copy link
Contributor

Choose a reason for hiding this comment

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

2.33.0 is still missing ".heif" and ".hif".

Also, libheif from 1.17 supports the JPEG 2000 codec inside the HEIF container w/ a ".hej2" extension, see https://www.itu.int/rec/T-REC-T.815/en

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe create a new issue about the multiple extensions of HEIF?

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.

heif format / .heic image file support
4 participants