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

Heic decoding #1375

Open
zdcthomas opened this issue Nov 18, 2020 · 19 comments
Open

Heic decoding #1375

zdcthomas opened this issue Nov 18, 2020 · 19 comments

Comments

@zdcthomas
Copy link

How does one decode an heic encoded image? Is there a current way that I'm missing to decode an heic image, OR convert it to an image format that I can also operate on, like a jpeg?

Overall, I'm trying to resize an heic encoded image.

I saw that there isn't decoding support for avif, but I'm more specifically interested in heic encoded images.
Thanks!
Sorry if this is an obvious question!

@fintelia
Copy link
Contributor

That isn't possible with this library yet. My suggestion would be to use an external tool to do the conversion like say ImageMagick

@zdcthomas
Copy link
Author

Is there something blocking development on that functionality/ is there anyone currently working on that?

@HeroicKatora
Copy link
Member

HeroicKatora commented Nov 19, 2020

There are a few ways to wrap libheif and mp4parse but I'm not aware of any Rust native crate that is specifically dedicated to generically demuxing isobmff as heif, nor to H.265 decoding. I imagine this is in parts due to the large patent encumbrance surrounding all of MPEG's technical work. This of course precludes the availabilty of HEIC decoding and encoding.

@est31
Copy link
Contributor

est31 commented Nov 25, 2020

I think instead of HEIC one should focus resources onto AVIF: #1152

The patent situation there is way better.

@mleonhard
Copy link

When iOS users enable the "live photo" option, their camera software creates HEIC files. My rust server must process those files.

My plan is to make my app convert all images to JPEG before uploading. I will try the Dart library https://pub.dev/packages/heic_to_jpg in my Flutter app.

@yuribudilov
Copy link

Hello everyone. Are there any positive news on this matter now in Dec 2021 ?
I would like to use Rust to convert .HEIC photo images to JPG/JPEG photo images and save resulting JPG on disk.
Right now I am using a GUI program to do it manually, which works OK but I am looking for a Rust-based programmatic solution to deal with HEIC photos. Thank you for any guidance.

@fintelia
Copy link
Contributor

This issue (like similar issues for other large feature requests) is blocked on either someone coming by that wants to implement it, or else another Rust crate being written that exposes the desired functionality in a way we can use.

I know it is not the answer you were hoping for, but sadly at this point none of the maintainers have the time and energy to make big feature additions. Which means that the majority of development comes down to contributors stepping in to write features they want for themselves, and of course we can't really predict when/if that'll happen for any given request

@baumanj
Copy link

baumanj commented Dec 29, 2021

Just a note that while mp4parse gets most of the way there on account of AVIF and HEIC being very similar at the container level, the hard problem of HEIC support is that the patents which cover the codec itself are not free. The best way forward would probably be to integrate libheif (perhaps via https://crates.io/crates/libheif-sys) to handle decoding. With that, the changes to mp4parse to get HEIC files demuxed should be pretty minimal.

@broes5
Copy link

broes5 commented May 22, 2023

I would like be able to use Image-rs to decode .heic files in a program I'd like to write. I wouldn't mind adding support for .heic files. Unfortunately I can't find any specific enough information about the structure of .heic files. If someone could point me in the right direction, I'm sure I'd figure it out eventually.

@baumanj
Copy link

baumanj commented May 22, 2023

HEIC has basically the same container structure as AVIF since they're both based on the ISO/IEC 23008-12:2017 HEIF standard (free download). This library already uses https://github.com/mozilla/mp4parse-rust, which I added AVIF parsing support to, so most of that work is done.

That said, they AVIF and HEIC differ at the codec level. AVIF uses AV1, while HEIC uses HEVC, which is neither free nor open. If you're interested, I'd suggest starting with https://github.com/strukturag/libde265. It doesn't seem to have a rust wrapper yet, so that'd be a nice community addition.

@broes5
Copy link

broes5 commented May 23, 2023

Thanks. What do you mean when you say that HEVC "is neither free nor open"?

@baumanj
Copy link

baumanj commented May 24, 2023

I mean that unlike AV1, HEVC is not free to use and there's no open source reference implementation

@CaiJingLong
Copy link

I would like be able to use Image-rs to decode .heic files in a program I'd like to write. I wouldn't mind adding support for .heic files. Unfortunately I can't find any specific enough information about the structure of .heic files. If someone could point me in the right direction, I'm sure I'd figure it out eventually.

The heic is base of ISO bmff(ISO_base_media_file_format).

https://en.wikipedia.org/wiki/ISO_base_media_file_format
https://mpeg.chiariglione.org/standards/mpeg-4/iso-base-media-file-format


I know an open source project of heif: https://github.com/nokiatech/heif

@broes5
Copy link

broes5 commented Aug 12, 2023

Is anyone here aware of libheif-rs? It's a wrapper around another library and is dependent on the libheif binary being installed. Has anyone considered using it in this project? I imagine getting image to be able to decode and encode .heic files using libheif-rs would be a lot simpler/easier than implementing the functionality from scratch or using another library.

@broes5
Copy link

broes5 commented Aug 12, 2023

Are there any reasons libheif-rs cannot be used or would be undesirable?

@fintelia
Copy link
Contributor

The two concerns with linking to libhief would be:

  1. We have a policy of only allowing non-Rust dependencies behind a disabled by default feature flag
  2. Patents. It'd probably be a headache to figure out what we can and cannot do, and to make sure we're not taking on any legal risk

@broes5
Copy link

broes5 commented Aug 12, 2023

There seem to be 3 libraries that are dependent on libheif installed on my laptop. If they can use it, then surly so can image without legal repercussions. Right?

@fintelia
Copy link
Contributor

I have no idea. Maybe they've consulted lawyers and take specific precautions? Or the developers are in a country where it isn't as much of a concern? Or it could just be a matter of time until they run into problems

@broes5
Copy link

broes5 commented Aug 13, 2023

One of them is called OpenImageIO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants