Format conversion
use SomehowDigital\ImgProxy\Url;
$base = Url::create()->source('https://example.com/photos/cat.jpg');Set the output format
Section titled “Set the output format”Pass the format to build(). It becomes the extension of the URL.
use SomehowDigital\ImgProxy\Option\Width;
$base->options(new Width(800))->build('webp');// _/w:800/plain/https%3A%2F%2Fexample.com%2Fphotos%2Fcat.jpg@webpQuality per format
Section titled “Quality per format”use SomehowDigital\ImgProxy\Option\FormatQuality;use SomehowDigital\ImgProxy\Option\Width;
$base->options(new Width(800), new FormatQuality(['webp' => 75, 'avif' => 60, 'jpeg' => 82]))->build();// _/w:800/fq:webp:75:avif:60:jpeg:82/plain/https%3A%2F%2Fexample.com%2Fphotos%2Fcat.jpgTransparency to JPEG
Section titled “Transparency to JPEG”JPEG has no alpha channel, so fill the transparent areas.
use SomehowDigital\ImgProxy\Option\Background;use SomehowDigital\ImgProxy\Option\Width;
$base->options(new Width(400), new Background('ffffff'))->build('jpg');// _/w:400/bg:ffffff/plain/https%3A%2F%2Fexample.com%2Fphotos%2Fcat.jpg@jpg