typo3webptypo3-12.x

Extension to convert images to .webp format is not working


I am working on a local Composer based installation of TYPO3 v12.4 (I cannot update to v13) and have installed the extension 'plan2net/webp' to convert all of my images to .webp-format. But for some reason the extension is not converting any images at all.

Here is what I tried to make the extension work:

  1. Add webp to generally allowed file formats:

    $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] .= ',webp';
    
  2. Installed the extension via

    ddev composer require "plan2net/webp"
    
  3. Checked in the backend module that the extension is installed and stable.

  4. Following the extension manual, I have then flushed TYPO3 and PHP Cache and cleared the processed files in the Maintenance module. Also updated the Database Structure**. At this point** I would expect the extension to generate a copy of each image and save it as webp. However, this is not the case if I check the files within the processed folder.

  5. Then I added this to my .htaccess file within :

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{HTTP_ACCEPT} image/webp
     RewriteCond %{REQUEST_FILENAME} (.*)\.(png|gif|jpe?g)$
     RewriteCond %{REQUEST_FILENAME}\.webp -f
     RewriteRule ^ %{REQUEST_FILENAME}\.webp [L,T=image/webp]
    </IfModule>
    

    And yes, mod_rewrite.c is enabled.

  6. At the bottom of the htaccess file I added:

    <IfModule mod_headers.c>
        <FilesMatch "\.(png|gif|jpe?g)$">
            Header append Vary Accept
        </FilesMatch>
    </IfModule>
    
  7. Last step was to flush TYPO3 and PHP Cache and to clear the processed files again.

    What am I missing?


Solution

  • Does your system match the requirements for webp?

    You can either use the installed Imagemagick or GraphicsMagick you already use for TYPO3 image manipulation if it supports webp (see below) or you can use any other external binary available on your server (e.g. cwebp).

    You can test the support of GraphicsMagick with e.g.:

    gm version | grep WebP

    (should return yes)

    or using ImageMagick with e.g.:

    convert version | grep webp

    (should return a list of supported formats including webp)

    You can check the support of webp via phpinfo(): Screenshot display ImageMagick part of phpinfo()-output


    DDEV

    In the case of older ddev, you must add webimage_extra_packages: [webp] to your config.yaml.

    Imagemagick and gd both seem to include webp support out of the box in recent versions of ddev.

    https://github.com/ddev/ddev/issues/1780