lovell / sharp-libvips

Packaging scripts to prebuild libvips and its dependencies - you're probably looking for https://github.com/lovell/sharp
Apache License 2.0
178 stars 100 forks source link

Enhancement: consider AVIF HDR support #247

Open jcayzac opened 2 months ago

jcayzac commented 2 months ago

Feature request

What are you trying to achieve?

Transform HDR AVIF images.

With both the AVIF format and HDR displays now being pretty much baseline, maybe it's time to start shipping prebuilt binaries that do support that?

When you searched for similar feature requests, what did you find that might be related?

I found an issue with a similar title, which was closed as "Completed" although Sharp still doesn't have HDR support.

What would you expect the API to look like?

No change in API, but using bitdepth: 10 in AvifOptions doesn't trigger an Expected 8 for bitdepth when using prebuilt binaries but received 10 of type number error. This means building libvips with HDR support.

What alternatives have you considered?

I think I have to look into trying to build binaries from source. Given I'm building my websites on the cloud (cloudflare pages) it's going to take some time to vendor the right binaries I guess.

Please provide sample image(s) that help explain this feature

https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Netflix

jcayzac commented 2 months ago

Issue lovell/sharp#4031 was also closed, despite no working solution.

lovell commented 2 months ago

I think I have to look into trying to build binaries from source.

Yes, sharp supports a globally-installed libvips compiled with support for a combination of libheif and HDR-enabled libaom, which is the correct approach should the prebuilt binaries not meet your needs.

jcayzac commented 2 months ago

@lovell So, I guess my feature request would be to have the prebuilt binaries support HDR? It's probably going to be raised more and more often…

lovell commented 2 months ago

The only decent HDR displays I've seen are based on OLED tech, which provides the required brightness range. Mid to high end phones with smaller displays are increasingly using this, but larger panels are still relatively expensive. As you say, at some point this will change, but we're not there yet.

Perhaps you could investigate to see if the P3 ICC profile provides a more appropriate gamut than sRGB for the sort of devices your scenario needs to support?

jcayzac commented 1 month ago

My mistake. I thought the baseline of desktop displays on sale now supporting HDR10 meant usage was growing. It seems significant enough for all major browsers to already support HDR AVIF so it's now a baseline web capability according to MDN.

lovell commented 1 month ago

I've moved this issue to the sharp-libvips repo, which is home of the scripts that create the prebuilt libvips binaries and where this future possible enhancement would need to be tackled first.

The discussion at https://github.com/Fyrd/caniuse/issues/6504 provides a good background on how support for this is slowly making its way (e.g. behind flags and with limitations) into web browsers. We should wait for the caniuse issue to be implemented/closed before continuing here.

Another thing to think about is that previous testing suggested HDR support in libaom increases its binary size by at least 2MB, so this needs to be checked/considered/minimised where possible.