h2non / imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing
https://fly.io/docs/app-guides/run-a-global-image-service/
MIT License
5.52k stars 456 forks source link

Support AVIF #337

Open GNURub opened 3 years ago

GNURub commented 3 years ago

I'd like to submit a proposal for a future feature to consider.

https://netflixtechblog.com/avif-for-next-generation-image-coding-b1d75675fe4

Format comparison: https://jakearchibald.com/2020/avif-has-landed/

jcupitt commented 3 years ago

Hello all, libvips has supported AVIF since version 8.9 -- it's just a question of building with the right set of supporting libraries.

On ubuntu 20.04, for example, install libheif-dev before configuring libvips, and you'll get full read / write support for AVIF as well as HEIC.

dariobarrio commented 3 years ago

hello @jcupitt , thank you very much for all the effort, i've one question regarding the AVIF support, when you say "the right set of supporting libraries", do you know of any guide to get it work? and just by doing that we can pass type=avif and will work out-of-the-box?

Thanks!

jcupitt commented 3 years ago

It should just work on macos with brew. On most linuxes you'll probably need to build your own libheif, and that'll need rav1e, dav1d or libaom for AVIF support.

smartinov commented 2 years ago

Hi everyone, any news on this issue?

seeruk commented 1 year ago

The AVIF support mentioned seems to indicate that reading AVIF files is supported, but that outputting as AVIF is not. Is AVIF output not possible?

jcupitt commented 12 months ago

Full read and write of AVIF works fine, and has done since 2019. It's out of the box on at least Debian, Homebrew and Windows, on other platforms you might need to build libvips yourself, depending.

jcupitt commented 12 months ago

... to give a bit more info, HEIC and AVIF use the same container format, called HEIF, but with different codecs. HEIC uses h265 and AVIF uses AV1.

https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format

libvips has heifload and heifsave for read and write of HEIC and AVIF files, and they call into libheif for low-level read and write of pixel data.

https://github.com/strukturag/libheif

libheif just handles the container. It in turn calls off into separate codec libraries for compress and decompress of pixel values. You need to be slightly cautious about which decode and encode libraries you select, as they have different licenses, and different performance profiles.

tldr: usually it'll just work. If you have to start building things (you're quite unlucky if this is really necessary), you'll need to think about decompress and recompress libraries, the container library, and libvips.