Not much longer will websites require PNG/JPG fallback for WebP used on the web.
As far as what file formats should be converted to WebP, PNG seems to be the main one:
Converting a JPG -> WebP will retain JPG's sub-par quality at a slightly smaller file size, but converting PNG -> WebP will significantly reduce file size without sacrificing PNG's great image quality. So, maybe an option to convert PNGs -> WebP would make the most sense?
Libraries for converting to WebP
As far as what library could be used, Google has libwebp which looks a little difficult to integrate into an Electron application. Alternatively, there's cwebp which is Google's CLI-friendly version that uses libwebp, which node could run if cwebp is installed. But, getting the user to install it or shipping cwebp with Electron is the tricky part.
WebP support
Feature: A config option to also convert images to WebP or convert specific formats to WebP (like PNG)
WebP now has support on all major browser: https://caniuse.com/webp
Not much longer will websites require PNG/JPG fallback for WebP used on the web.
As far as what file formats should be converted to WebP, PNG seems to be the main one:
Converting a JPG -> WebP will retain JPG's sub-par quality at a slightly smaller file size, but converting PNG -> WebP will significantly reduce file size without sacrificing PNG's great image quality. So, maybe an option to convert PNGs -> WebP would make the most sense?
Libraries for converting to WebP
As far as what library could be used, Google has
libwebp
which looks a little difficult to integrate into an Electron application. Alternatively, there'scwebp
which is Google's CLI-friendly version that useslibwebp
, which node could run ifcwebp
is installed. But, getting the user to install it or shippingcwebp
with Electron is the tricky part.A somewhat maintained JS wrapper for
cwebp
(library has acwebp
binary in it): https://github.com/imagemin/cwebp-binAn example of Apache's "Echarts" repo using the
cwebp-bin
in practice: https://github.com/apache/echarts-examples/blob/00e79accd3f1ac638774ae56b84e845d616a3124/tool/build-example.js#L91A library that supports converting a number of different formats, including webp: https://github.com/Yuriy-Svetlov/compress-images