diff options
Diffstat (limited to '')
-rwxr-xr-x | share/extensions/raster_output_webp.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/share/extensions/raster_output_webp.py b/share/extensions/raster_output_webp.py new file mode 100755 index 0000000..01d728f --- /dev/null +++ b/share/extensions/raster_output_webp.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +""" +Convert PNG to WebP using Raster Output extension. +""" + +import inkex + + +class WebpOutput(inkex.RasterOutputExtension): + def add_arguments(self, pars): + pars.add_argument("--tab") + pars.add_argument("--quality", type=int, default=80) + pars.add_argument("--speed", type=int, default=0) + pars.add_argument("--lossless", type=inkex.Boolean, default=True) + + def save(self, stream): + self.img.save( + stream, + format="webp", + quality=self.options.quality, + lossless=self.options.lossless, + method=self.options.speed, + ) + + +if __name__ == "__main__": + WebpOutput().run() |