Bug 356931

Summary: webp is saved in very low quality (like -q 0)
Product: [Applications] gwenview Reporter: FabiB <plusfabi>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: major CC: myriam, nate
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugreports.qt.io/browse/QTBUG-64437
Latest Commit: Version Fixed In:

Description FabiB 2015-12-20 05:17:15 UTC
since plasma now supports webp natively i wanted to convert my wallpapers to webp to save some spave on my ssd.
first i tried with "cwebp" (the native convert tool and even without an option for quality (-q 0-100) it does a good job.

but i wanted to try gwenview too. gwenview seems to set to quality option to 0. so its maximum small but the quality is bad. you cant use the picture after that anymore.

Reproducible: Always

Steps to Reproduce:
1. find some good picture and open it with gwenview
2. file -> save as -> name.webp
3. close gwenview(!) and open you newly created webp

Actual Results:  
its really bad quality.. you'll just see artifacts

Expected Results:  
it should be in the same quality as with the tool cwebp 

Usage:

   cwebp [options] -q quality input.png -o output.webp

where quality is between 0 (poor) to 100 (very good).
Typical value is around 80.
Comment 1 Nate Graham 2017-11-10 18:31:02 UTC
Oh wow, this is horrible.
Comment 2 Nate Graham 2017-11-10 20:00:30 UTC
Looks like we're just using the standard QImageWriter. From documentloadedimpl.cpp:

bool DocumentLoadedImpl::saveInternal(QIODevice* device, const QByteArray& format)
{
    QImageWriter writer(device, format);
    bool ok = writer.write(document()->image());
    if (ok) {
        setDocumentFormat(format);
    } else {
        setDocumentErrorString(writer.errorString());
    }
    return ok;
}

This seems to be Qt bug in how webp images are saved; adding "writer.setQuality(100);" before we call writer.write() doesn't have any effect. I've filed https://bugreports.qt.io/browse/QTBUG-64437