pstaender/high-quality-low-size-image-for-kirby

Converts images to low file size high quality images in webp and avif

0.0.9 2023-07-01 13:30 UTC

This package is auto-updated.

Last update: 2024-04-28 06:39:01 UTC


README

Install

$ composer require pstaender/high-quality-low-size-image-for-kirby

Usage

<?= $page->someImage()->toFile()->highQualityLowSize() ?>

Now your image will be a webp or avif instead of jpg/png/etc 🚀

Webp will be the format if gdlib is available, avif if imagemagick is enabled via thumb driver.

It also checks that the browser supports webp and avif via the accept header and returns the original file if not supported.

Optional: Image Tag

To use it also in kirby text (via image tag) set in config.php:

[
    'high_quality_and_low_size_image' => [
        'image_tag' => true,
    ],
]

You can exclude specific image formats from encoding, by default gif, webp and avif are excluded. To set your own rules or to simply force re-encoding every file (by defining an empty array), set the values here:

[
    'high_quality_and_low_size_image' => [
        'excluded_image_formats' => [
            // 'avif', 'webp', …
        ],
    ],
]

License

MIT