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

AVIF support in prebuilt binaries #2289

Closed
asilvas opened this issue Jul 10, 2020 · 24 comments
Closed

AVIF support in prebuilt binaries #2289

asilvas opened this issue Jul 10, 2020 · 24 comments

Comments

@asilvas
Copy link

asilvas commented Jul 10, 2020

AVIF is coming soon to the most popular browsers. Is there a reason this is still considered experimental and not ready for production? https://sharp.pixelplumbing.com/api-output#heif

@lovell
Copy link
Owner

lovell commented Jul 13, 2020

Hi Aaron, I expect to be able to include aom+libheif in the prebuilt binaries in order to support AVIF input and output, but the following things will need to exist first, in approximately this order:

Anything you can do to help with the first two security-related items will be much appreciated.

(The patent-encumbered HEIC codec will not be supported in the prebuilt binaries.)

@asilvas
Copy link
Author

asilvas commented Jul 13, 2020

Thanks! I'll close.

@lovell
Copy link
Owner

lovell commented Aug 29, 2020

I'm going to reopen this to become the "canonical" issue to track adding AVIF support in the prebuilt binaries.

For anyone else coming to this issue, sharp already supports AVIF, you need to compile libvips from source with support for libheif that has been compiled with support for aom/rav1e, before installing sharp.

@lovell lovell reopened this Aug 29, 2020
@lovell lovell changed the title Why is HEIF experimental still? AVIF support in prebuilt binaries Aug 29, 2020
@lovell
Copy link
Owner

lovell commented Sep 6, 2020

I've created google/oss-fuzz#4414 to enable fuzz testing of AVIF images with libheif, see step 1 above. Once approved and merged, my plan is to let that run for a couple of weeks to give it a chance to find any problems and get them fixed before moving onto step 2.

@soukicz
Copy link

soukicz commented Sep 14, 2020

my plan is to let that run for a couple of weeks to give it a chance to find any problems and get them fixed before moving onto step 2.

Is that something that would benefit from having some monster AWS EC2 server? I don't know much C but I do have credit card :)

@lovell
Copy link
Owner

lovell commented Sep 14, 2020

@soukicz OSS-Fuzz runs on Google's ClusterFuzz hardware, currently >25k cores of processing power.

@lovell
Copy link
Owner

lovell commented Sep 21, 2020

The addition of AVIF fuzzing to libvips is now merged at google/oss-fuzz#4463 - let's see what it finds in the next few days before moving onto step 3.

@lovell
Copy link
Owner

lovell commented Sep 25, 2020

There's lots of interest in this issue so I'd like to remind everyone that if you work at a for-profit organisation, and you are not already doing so, then please donate to https://opencollective.com/libvips if you benefit commercially from sharp and libvips.

@lovell
Copy link
Owner

lovell commented Oct 13, 2020

Prebuilt binaries containing libvips, libheif and aom have now been successfully built for Linux (x64, ARMv6, ARMv7, ARM64), macOS (x64) and Windows (x64, x86). A groot big thank you to @kleisauke for help with these.

This means those feeling brave may want to carry out some early/alpha testing.

npm install lovell/sharp#avif

Given installation is from GitHub rather than npm, the above command will require node-gyp and its dependencies (C++ compiler, Python) - see https://sharp.pixelplumbing.com/install#building-from-source

The following code samples are made possible when using these pre-release binaries:

// AVAILABLE FROM v0.27.0+

await sharp(input).toFile("out.avif");

await sharp("in.avif").toFile("out.jpg");

await sharp(input).avif({ quality: 30, speed: 1 }).toBuffer();

// AVAILABLE FROM v0.27.0+

Temporary docs for the forthcoming avif() can be viewed at https://github.com/lovell/sharp/blob/avif/docs/api-output.md#avif

Please do not use these in production systems yet.

@lovell
Copy link
Owner

lovell commented Oct 31, 2020

Fuzz tests added for this issue are (un)fortunately still finding security bugs in AVIF-related dependencies, approximately one every ~5 days, so this this not yet ready for release. Please do not use these in production systems yet.

@virgofx
Copy link

virgofx commented Nov 2, 2020

@lovell Any chance you could shed some more insight into your last comment? If there are a few random bugs would it be possible to still utilize the avif format in a release and then have subsequent build releases address security concerns in libvips? I guess at some level there will always be issues with dependencies. If the sharp app works well with the format yet there are a few downstream issues, couldn't those just be updated and re-released in minor patch builds?

@lovell
Copy link
Owner

lovell commented Nov 2, 2020

@virgofx If your question can be rephrased as "Will pre-compiled binaries be provided that contain known security vulnerabilities?" then the answer is "no".

@ascorbic
Copy link
Contributor

ascorbic commented Dec 1, 2020

@lovell Is there an area where time/resources could be invested to get this over the line, or is this just lots of bugs in various dependencies?

@tomgallagher
Copy link

As a side issue, I had read that encoding and decoding AVIF files was very slow. Are there any performance stats on this with libvips?

@lovell
Copy link
Owner

lovell commented Dec 1, 2020

@ascorbic There are a number of security-related fixes in libheif and libvips awaiting release.

There are also a couple of open bugs relating to the use of clap (clean aperture) boxes:

@AndreiIgna
Copy link

When this is shipped it will make sharp even more helpful than already is 🎉

@lovell
Copy link
Owner

lovell commented Dec 18, 2020

libheif v1.10.0 and libvips v8.10.5 have now been released, plus (sadly but understandably) all the pubs in London are pandemically-shut, which means we're looking at this side of Christmas for a release of sharp that includes prebuilt binaries that support AVIF. 🎉

@lovell
Copy link
Owner

lovell commented Dec 21, 2020

If anyone would like to test the v0.27.0-beta1 pre-release, which includes prebuilt binaries for all the usual platforms, please use the following (this doesn't require a compiler, but does involve a git checkout of the whole repo so will still be slower than an npm-published package):

$ npm install lovell/sharp

I plan to publish this to npm as v0.27.0 tomorrow.

@lovell
Copy link
Owner

lovell commented Dec 22, 2020

sharp v0.27.0 is now available with prebuilt binaries that contain libaom and libheif for full AVIF decoding and encoding support.

Please note the current lack of support in most browsers for AVIF images smaller than 16x16.

https://sharp.pixelplumbing.com/api-output#avif

If anyone discovers a problem image, please open a new issue and provide as much information as possible, ideally trying libheif's command line tools such as heif-convert first to ensure it is not an upstream issue - https://github.com/strukturag/libheif#example-programs

@lovell lovell closed this as completed Dec 22, 2020
@joehoyle
Copy link

Amazing, thanks so much @lovell, I had done some work to update humanmade/tachyon#130 to the sharp branch, sorry I didn't manage to get beta-1 testing in time. So far everything looks to be working well!

@lovell
Copy link
Owner

lovell commented Dec 22, 2020

Here's a basic CLI tool to quickly/easily transcode a directory of images into AVIF, which might be useful to help assess the suitability of AVIF for a particular task.

https://www.npmjs.com/package/avif

Run npx avif --help for usage instructions.

@lovell
Copy link
Owner

lovell commented Dec 22, 2020

Reminder: if you work at a for-profit organisation that benefits commercially from sharp and libvips then please tell your manager to become a backer at https://opencollective.com/libvips

@ascorbic
Copy link
Contributor

Reminder: if you work at a for-profit organisation that benefits commercially from sharp and libvips then please tell your manager to become a backer at https://opencollective.com/libvips

That's awesome news @lovell. I'll certainly be raising this.

@ascorbic
Copy link
Contributor

ascorbic commented Dec 27, 2020

As a note to anybody using Apple Silicon who wants AVIF support: bear in mind that before compiling libvips from source you will need to compile and install libheif and aom from source too. Using homebrew doesn't work either, and it will either fail to include AVIF support, or it will include it but fail to generate images. You must first compile and install aom from git, then compile and install libheif (checking that it has found aom when running configure), then finally compile and install libvips.

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

8 participants