'Libvips PHP: How to make WEBP file with given compression?

I have code that converts and resize jpg to webp. One thing I can't solve: how to set compression. Code is like that:

use Jcupitt\Vips;

$vips = Vips\Image::newFromFile('src_file.jpg');

$thumb1 = $vips->thumbnail_image(1200);

$thumb1->writeToFile('new_name.webp');

This code works and uses default compression. But I want to make file size smaller. Tried following adjustments to code:

$thumb1 = $vips->thumbnail_image(1200, ['Q=2,optimize_coding']);
$thumb1 = $vips->thumbnail_image(1200, ['Q=2']);
$thumb1->writeToFile('new_name.webp', ['Q=2']);

and many more variants but file size doesn't change. Please help.



Solution 1:[1]

The solution:

$thumb1->writeToFile('new_name.webp', ['Q' => 2,'min-size' => true]);

Docs: https://libvips.github.io/php-vips/classes/Jcupitt-Vips-Image.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rolling