Skip to content

Add support for HEIF based images #2633

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

Open
wants to merge 260 commits into
base: main
Choose a base branch
from
Open

Conversation

ynse01
Copy link
Contributor

@ynse01 ynse01 commented Dec 29, 2023

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This PR is an attempt to start with #1320

Implemented decoding and encoding of images based on a HEIF (ISO/IEC 23008-12:2022) container. These include (amongst others): HEIC, HIF and AVIF.

Please note this PR does NOT add any new compression algorithm to ImageSharp. For now it will take a JPEG thumbnail as its pixel source.
Needless to say, much more work is needed after this PR to reach the goal. I'm try to help there also.

Please do let me know any comments, also on whether to support the HEIF file format in the first place.

@JimBobSquarePants
Copy link
Member

Oh wow! Thanks! 🙏 I’ll have a good dig through asap!!

@dlemstra
Copy link
Member

dlemstra commented Jan 4, 2024

I noticed that you used the x265 encoder. This is licensed under the GPL and cannot be used in this project.

@ynse01
Copy link
Contributor Author

ynse01 commented Jan 5, 2024

I noticed that you used the x265 encoder. This is licensed under the GPL and cannot be used in this project.

True, and that is why I used the Nokia repository as reference for my implementation, which has a license which I guess is compatible with ImageSharp. I did not start on writing an HVC Codec, due to patent concerns.

Nokia also includes a Patent waiver in its license. AVIF is supposed to be patent free, even its Codec. For AVIF I used SVT-AV1 as a reference, which has a 3-clause BSD license.

With all this, I hope the reference implementations that are mentioned now, can be used to create an AVIF Codec implementation in ImageSharp.

@jaddie
Copy link

jaddie commented Feb 5, 2025

Not sure if its suitable to do so or not, but putting this comment on as a appreciation of the effort but also a vote for avif support and anyone seeing this who is after it can thumbs this up to show their desire too as it would be great as the storage saving is fantastic as a result of avif vs jpg for sure along with the wide support existing now.

Edit: Silly me, just thought to put an additional heart reaction on the original PR post, woops!

@ADNewsom09 ADNewsom09 mentioned this pull request Feb 25, 2025
4 tasks
@axtox
Copy link

axtox commented Jul 16, 2025

is this still active? really waiting for this feature!

@ynse01
Copy link
Contributor Author

ynse01 commented Aug 13, 2025

is this still active? really waiting for this feature!

I'm still here. But after several attempts to crack the Entropy Encoding, I figured I need a break to start with a fresh mind.
So, unfortunately, this PR will take a little bit more time to complete than expected.

@axtox
Copy link

axtox commented Aug 14, 2025

is this still active? really waiting for this feature!

I'm still here. But after several attempts to crack the Entropy Encoding, I figured I need a break to start with a fresh mind. So, unfortunately, this PR will take a little bit more time to complete than expected.

I am now adopting ImageSharp.Heif nuget package, but it's out of date and does not work with iPhone >15 HEIF formats because it is using libheif version 1.15.1, meanwhile the latest is 1.20.2. I even tried to build C++ native libs that they are using - no luck. Check out the issue in their repo if you're curious.

maybe you can peek some ideas on cracking the Entropy Encoding from the original libd265/libheif authors repo from here (libd265, the h.265 codec for image and video processing, written in C++), or here (libheif, written in C++ uses libd265 for HEIC decode and other libs to encode and decode formats), or maybe here (libheif-sharp, written with C# and uses C++ libheif API calls)?

both C# ImageSharp.Heif and libheif-sharp projects are using native C++ libs API's that are built and packed as nuget package with C++ binaries

maybe that'll help! thank you for your effort, looking forward to hear any updates from you.

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.

8 participants