AVIF support is not available in your version of PHP, since Kirby Update to 4

Since updating a project from Kirby 3.9.x to Kirby 4 I get the following error message “AVIF support is not available in your version of PHP.”

In previous versions this did not cause any problems. I am using Mamp Pro (Mac) and PHP 8.2.0.

Does anyone have an idea how I can fix this?

Hi,

I have the same problem on the server. I just updated a Kirby 3.x website → 4.x, deleted the media folder and now I get the following error.

  1. file: “/vendor/claviska/simpleimage/src/claviska/SimpleImage.php”
  2. line: 420
  3. message: “AVIF support is not available in your version of PHP.”
  4. status: “error”

This is strange cause it worked with the older kirby version.


              <picture>
                <source srcset="<?= $thumb->thumb(['format' => 'avif'])->url() ?>" type="image/avif">
                <source srcset="<?= $thumb->thumb(['format' => 'webp'])->url() ?>" type="image/webp">
                <img class="hero-main-img" alt="Hero"  src="<?= $thumb->thumb(['format' => 'png'])->url() ?>">
              </picture>

How can it be that the avifs were generated with the Kirby 3.x version even though the php module is missing on the server. But now with v4 not anymore?

And why doesn’t it use the webp source if the avif file doesn’t exist, that’s actually the point of using “sources”.

A missing image is simply displayed, as if the source function was being disabled.

Hmm maybe because the missing file returns a 500 error instead of a 404.

Could that be?

Could have happened because Kirby 3 in case of a missing driver just copied the files as is without throwing an error, now no files are generated.

Are you using the standard GD driver or IM?

What is your version of PHP and what does phpinfo() tell you in the GD section (if that’s what you are using).

Hi, happy new year ;)!

We are using php 8.1, and and don’t have set a special driver, so default GD.
GD is NOT installed on this server ( [“AVIF Support”]=> bool(false)) but what you said about kirby 3 makes sense now and this is why it worked before.

If we change the source, first webp than avif, the images is shown correctly.

I think it’s really the 500 error that blocks skipping the missing image source.

BR

To change the driver to IM, works!

1 Like

I’m having the same error in a similar scenario. I also updated from Kirby 3 to 4. locally avif is generated but once I upload to my server images are not generated and on right click opening the image in a new tab I get the “AVIF support is not available in your version of PHP” error.

PHP 8.2 is running on my server locally and with my hosting provider. Just to be sure I contacted my hosting provider and they told me IM and php 8.2 can be used for avif.

when i check php info i don’t see any mention for avif in GD, only in IM

GD Support 	enabled 
GD headers Version 	2.3.0
GD library Version 	2.3.0
FreeType Support 	enabled
FreeType Linkage 	with freetype
GIF Read Support 	enabled
GIF Create Support 	enabled
JPEG Support 	enabled
PNG Support 	enabled
WBMP Support 	enabled
XPM Support 	enabled
XBM Support 	enabled
WebP Support 	enabled
BMP Support 	enabled
TGA Read Support 	enabled 

for now i just changed the order in my responsive image snippet (based on the responsive images guide), so i’m just not using avif. But If I want to use avif, from what I understand I need to change from the default GD to IM as a general image engine. (How to switch from GD to ImageMagic as image engine?)

c::set('thumbs.driver', 'im');

could tell me where i would plug that line into my config.php? that would change the engine for all image generation to IM? from what i understand at least for thumbs() IM is already the default?

<?php 
return [
    'debug' => true,

    'thumbs' => [
        'srcsets' => [
            'default' => [
                '300w'  => ['width' => 300],
                '600w'  => ['width' => 600],
                '900w'  => ['width' => 900],
                '1200w' => ['width' => 1200],
                '1800w' => ['width' => 1800]
            ],
            'avif' => [
                '300w'  => ['width' => 300, 'format' => 'avif'],
                '600w'  => ['width' => 600, 'format' => 'avif'],
                '900w'  => ['width' => 900, 'format' => 'avif'],
                '1200w' => ['width' => 1200, 'format' => 'avif'],
                '1800w' => ['width' => 1800, 'format' => 'avif']
            ],
            'webp' => [
                '300w'  => ['width' => 300, 'format' => 'webp'],
                '600w'  => ['width' => 600, 'format' => 'webp'],
                '900w'  => ['width' => 900, 'format' => 'webp'],
                '1200w' => ['width' => 1200, 'format' => 'webp'],
                '1800w' => ['width' => 1800, 'format' => 'webp']
            ],
        ]
    ]
];
<?php foreach ($page->images()->sortBy('sort') as $image): ?>
    <figure>

        <?php $sizes = "(min-width: 1200px) 25vw,
                        (min-width: 900px) 33vw,
                        (min-width: 600px) 50vw,
                        100vw"; ?>

        <picture>
            <source
                srcset="<?= $image->srcset('webp') ?>"
                sizes="<?= $sizes ?>"
                type="image/webp"
            >

            <source
                srcset="<?= $image->srcset('avif') ?>"
                sizes="<?= $sizes ?>"
                type="image/avif"
            >
            <img
                loading="lazy"
                alt="<?= $image->alt() ?>"
                src="<?= $image->resize(300)->url() ?>"
                srcset="<?= $image->srcset() ?>"
                sizes="<?= $sizes ?>"
                width="<?= $image->resize(1800)->width() ?>"
                height="<?= $image->resize(1800)->height() ?>"
            >
        </picture>

        <figcaption><?= $image->caption() ?></figcaption>

    </figure>

<?php endforeach ?>

Within this thumbs array:

 'thumbs' => [
        'driver' => 'im',
        'srcsets' => []
],

Note that you might have to also pass the path to the convert binary, see docs thumbs | Kirby CMS

Amazing—so quick, thank you it worked!

I realize this might be a bit of broader question: I’m just reading on performance comparisons in between IM and GD and webp vs avif I see people reporting different things, and am just wondering what is the reasoning for using IM over GD or avif over webp with kirby? Given that gd is the default and the responsive images guides is set up with avif in the example?