diff options
Diffstat (limited to '')
-rw-r--r-- | share/extensions/raster_output_jpg.py | 28 |
1 files changed, 28 insertions, 0 deletions
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() |