From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- share/extensions/raster_output_jpg.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 share/extensions/raster_output_jpg.py (limited to 'share/extensions/raster_output_jpg.py') diff --git a/share/extensions/raster_output_jpg.py b/share/extensions/raster_output_jpg.py new file mode 100644 index 0000000..4235044 --- /dev/null +++ b/share/extensions/raster_output_jpg.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +""" +Convert PNG to Jpeg using Raster Output extension. +""" + +import inkex + + +class JpegOutput(inkex.RasterOutputExtension): + multi_inx = True # XXX Remove this after refactoring + + def add_arguments(self, pars): + pars.add_argument("--tab") + pars.add_argument("--quality", type=int, default=90) + pars.add_argument("--progressive", type=inkex.Boolean, default=False) + + def save(self, stream): + self.img.convert("RGB").save( + stream, + format="jpeg", + quality=self.options.quality, + dpi=self.img.info["dpi"], + progressive=self.options.progressive, + ) + + +if __name__ == "__main__": + JpegOutput().run() -- cgit v1.2.3