rosell-dk / webp-convert

Convert jpeg/png to webp with PHP (if at all possible)
MIT License
576 stars 101 forks source link

Very low quality of resulting images on Windows #338

Open mihail-minkov opened 2 years ago

mihail-minkov commented 2 years ago

First of all, great library, really easy to use and also fast!

This is not a critical issue but it does cause me some complications on my local server.

I have the following setup:

I am using CodeIgniter 4.1.9 and WebpConvert 2.9.1 which I think is the latest version as per this post.

So, I use the following code:

$fuente = '1200x500_processed_file.jpg';
$destino = 'uploades/1200x500_processed_file.webp';
$opciones = [
    'converters' => ['gd'],
    'png' => [
        'encoding' => 'auto',    
        'near-lossless' => 60,   
        'quality' => 85,         
        'sharp-yuv' => true,
    ],
    'jpeg' => [
        'encoding' => 'auto',    
        'quality' => 'auto',     
        'max-quality' => 80,     
        'default-quality' => 75, 
        'sharp-yuv' => true,
    ]
];
WebPConvert::convert($fuente, $destino, $opciones);

If I use this on Ubuntu it works like a charm, but when I use it on Windows it completely ignores the quality settings and inputs extremely low quality images:

The JPG is previously compressed and resized accordingly, but as you can see in the example, the difference in quality is enormous.

Example:

Original processed JPG - 7.48 kb image

Webp converted file from the original JPG - 588 bytes image

Is there some issue with the library and Windows or am I configuring something incorrectly? I tried using imagemagick as a converter but I get PHP errors, that might be a config issue from my side.