diff options
Diffstat (limited to 'share/extensions/raster_output_tiff.py')
-rwxr-xr-x | share/extensions/raster_output_tiff.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/share/extensions/raster_output_tiff.py b/share/extensions/raster_output_tiff.py new file mode 100755 index 0000000..1594b7f --- /dev/null +++ b/share/extensions/raster_output_tiff.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +""" +Convert PNG to Tiff using Raster Output extension. +""" + +import io +import inkex + + +class TiffOutput(inkex.RasterOutputExtension): + def add_arguments(self, pars): + pars.add_argument("--tab") + pars.add_argument("--compression", default=None) + pars.add_argument("--quality", type=int, default=90) + + def save(self, stream): + tempstream = io.BytesIO() + self.img.save( + tempstream, + format="tiff", + compression=(self.options.compression or None), + dpi=self.img.info["dpi"], + quality=100, + ) + stream.write(tempstream.getvalue()) + # TODO: Add other fields such as copyright etc. + + +if __name__ == "__main__": + TiffOutput().run() |