I'm running
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
I'm also running ImageMagick 6.9.
I'd like to convert a PDF image into WebP. AFAIK, out of the box, ImageMagick on Linux cannot convert to WebP, so I sudo apt-get install webp
which installs cwebp
.
cwebp
allows to specify the -q
parameter, and ImageMagick allows to specify the -quality
parameter.
When I run $ cwebp -q 90 image.png -o image.webp
, it takes cwebp
around 8 seconds to convert it. If I run convert image.png -quality 90 image.webp
, it takes ImageMagick around 30 seconds to convert it. It seems like the -quality
parameter is not passed through to cwebp
. It also may be the case that convert
attempts to run a lossless conversion, which in cwebp
is achieved with an explicit -lossless
flag.
I run the test commands for a 10 MB test png image.
I would like to achieve 8 second conversion times with convert
command. How can I do it?
It turns out, that the delegates are invoked using the rules in /etc/ImageMagick-6/delegates.xml
.
It lists a bunch of rules on how to convert between different types of images.
For my case, the png
->webp
conversion, I needed the string:
<delegate decode="png" encode="webp" command=""cwebp" -quiet %Q "%i" -o "%o""/>
While in this file I don't know the -quaility
parameter value, and there seems to be no way to capture it.
However, if you wish to keep the value of the -q
parameter for cwebp
, you have the option of hard-coding the -q $YOUR_VALUE
right into the command
inside the delegate
tag.
This solution is still slower than invoking cwebp
directly, since ImageMagick can take up to 8 seconds before invoking the delegate.