Bug 420449 - add support for saving as (lossless) webp
Summary: add support for saving as (lossless) webp
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-23 09:23 UTC by Jos van den Oever
Modified: 2020-04-25 11:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jos van den Oever 2020-04-23 09:23:55 UTC
SUMMARY

Files saved by spectacle can be quite large. Using oxipng or optipng can often shave 30% of the size in a fraction of a second.

oxipng /tmp/Screenshot_20200423_111228.png
Processing: /tmp/Screenshot_20200423_111228.png
    1411x1217 pixels, PNG format
    4x8 bits/pixel, RGBA
    IDAT size = 285460 bytes
    File size = 285946 bytes
Trying: 8 combinations
Found better combination:
    zc = 9  zs = 0  f = 0        203982 bytes
    IDAT size = 203982 bytes (81478 bytes decrease)
    file size = 204060 bytes (81886 bytes = 28.64% decrease)
Output: /tmp/Screenshot_20200423_111228.png


Even more space can be saved by saving as lossless webp. Webp is supported in all new browsers. Making it the default is perhaps a bit early, but it would be nice if spectable would remember the preference for webp.

STEPS TO REPRODUCE

$ cwebp -lossless /tmp/Screenshot_20200423_111228.png -o /tmp/Screenshot_20200423_111228.webp
Saving file '/tmp/Screenshot_20200423_111228.webp'
File:      /tmp/Screenshot_20200423_111228.png
Dimension: 1411 x 1217
Output:    92618 bytes (0.43 bpp)
Lossless-ARGB compressed size: 92618 bytes
  * Header size: 2129 bytes, image data size: 90463
  * Lossless features used: SUBTRACT-GREEN
  * Precision Bits: histogram=5 transform=5 cache=10

OBSERVED RESULT

$ ls -l /tmp/Screenshot_20200423_111228.*
285946 23 apr 11:12 /tmp/Screenshot_20200423_111228.png
 92618 23 apr 11:13 /tmp/Screenshot_20200423_111228.web


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 19.12
(available in About System)
KDE Plasma Version:  19.12
KDE Frameworks Version: 5.66
Qt Version: 5.12.7

ADDITIONAL INFORMATION
Comment 1 David Redondo 2020-04-23 09:31:51 UTC
Spectacle can save in all file formats supported by QImageWriter. In fact on my machine I can select webp as file format resulting in 100 KiB 1920x1080 screenshots.
Comment 2 Jos van den Oever 2020-04-23 09:56:00 UTC
That's great to hear. I've plugins/imageformats/libqwebp.so on my machine but do not see an option to save to webp or set it as a default format.

Is there an option to save losslessly? webp can save lossy and losslessly and often for screenshots the lossless version is smaller as well as more accurate.
Comment 3 Jos van den Oever 2020-04-24 18:56:45 UTC
After installing the Qt image plugins, spectacle can save as webp. Very nice!

When I save images with webp 100% quality the files are much smaller than when saving with 99% quality.

E.g. a screenshot of a browser is 366K when saving at 99% quality and 197K when saving at 100% quality.
Comment 4 Christoph Feck 2020-04-25 11:13:06 UTC
The quality setting in Qt image plugins controls compression, and with WebP, 100 forces lossless mode

https://code.qt.io/cgit/qt/qtimageformats.git/tree/src/plugins/imageformats/webp/qwebphandler.cpp#n274