-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hi @jcupitt
I'm having some strange issues with generating webp images with php-vips on Debian bookworm. The output file sizes are very large compared to using cwebp. Here are the results from generating a 16px webp from a 1200x1200 jpg:
// php-vips (webp)
Image::thumbnail($inputPath, 16)
->writeToFile(base_path('test.webp'), ['Q' => 20, 'strip' => true, 'reduction_effort' => 4]);
File size: ~24kb
// cwebp
$command = [
'cwebp',
'-resize',
16,
0,
'-q',
20,
$inputPath,
'-o',
base_path('test.webp'),
];
$process = new Process($command);
$process->run();
File size: 166 bytes (which is what I was expecting)
Even the jpg and png versions generated by php-vips are smaller than the webp version:
// php-vips (jpg)
$lqip = Image::thumbnail($inputPath, 16)
->writeToFile(base_path('test.jpg'), ['Q' => 20, 'strip' => true]);
File size: 620 bytes
// php-vips (png)
$lqip = Image::thumbnail($inputPath, 16)
->writeToFile(base_path('test.png'), ['Q' => 20, 'strip' => true]);
File size: 920 bytes
Any idea what might be happening? libvips and libwebp7 are both installed, and changing the Q value does change the file size (eg. 'Q' => 100 creates bigger files than 'Q' => 20). So I'm assuming webp is working.
The 16px images are saved as base64 and used as part of my LQIP system, so they need to be 100-200 bytes. I've switched over to cwebp for now but I'd like to get it working with php-vips if possible.