nystudio107 / craft-imageoptimize

Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.
https://nystudio107.com/plugins/imageoptimize
Other
235 stars 36 forks source link

AVIF support #225

Open kareljan opened 4 years ago

kareljan commented 4 years ago

It would be nice to have AVIF support in Image Optimize.

khalwat commented 4 years ago

So I did look into adding support for AVIF -- I think technically, you could add support for it right now if you wanted to, you'd just need to configure another image variant creator.

The issue is that the tooling around AVIF isn't that great right now. You either need to download a raw binary, or you need to install the Go runtime, and some other server-side setup that's a bit messy at the moment.

I'm very likely to support this soon-ish anyway, but keep in mind that the encoding time for AVIF images is also quite long.

kareljan commented 4 years ago

Hey Andrew Thanks for the response. It's true the technology has to mature a bit more. And browser support has to grow too. But nice to have it on the horizon.

khalwat commented 4 years ago

I'm going to keep this open if you don't mind... I do plan to do it!

danleecpi commented 2 years ago

I know we have talked this over too @khalwat - Just read this over at Smashing Magazine which might provide more insight on AVIF encoding improvements.

Since Jan 1st 2021, AVIF encoding had a ~47% improvement in transcode time (this is speed 6, the current default for libavif) and across the calendar year a 73% improvement. Since July, there’s also been a 72% improvement in transcode times at speed 9 (on-the-fly-encoding).

khalwat commented 2 years ago

Yeah the tooling is definitely getting there! One previously rather large downside is what it took to install the needed packages, but I'll see if that has improved as well.

jan-dh commented 1 year ago

Was wondering, is there any update on this? Not sure if it's easier atm to generate avif?

roelvanhintum commented 6 months ago

Is there any progress on this, with libavif being past 1.0.0?

khalwat commented 6 months ago

So technically ImageOptimize has always supported avif, or any other format you might want, via the config:

    'imageVariantCreators' => [
        // webp variant creator
        'cwebp' => [
            'commandPath' => '/usr/bin/cwebp',
            'commandOptions' => '',
            'commandOutputFileFlag' => '-o',
            'commandQualityFlag' => '-q',
            'imageVariantExtension' => 'webp',
        ],
    ],

ref: https://github.com/nystudio107/craft-imageoptimize/blob/develop-v4/src/config.php#L223

Where you can add whatever variant creator you want, including avif. But yes, I do want to formalize it now that it has reached 1.0.0 and is more widely accepted.

DavidKabelitz commented 2 months ago

@khalwat just a question to that one, will you integrate it soon or do we need to work with the workaround? Thx

khalwat commented 2 months ago

I don't have a timetable for adding AVIF support, primarily because it's so resource intensive that doing it on your own VPS is pretty rough. It's better to use a service that supports it imo.