diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index 0d7cfeac5965..170a67974542 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -625,14 +625,24 @@ def print_jpg(self, filename_or_obj, *args, **kwargs): # add TIFF support def print_tif(self, filename_or_obj, *args, **kwargs): + """ + Other Parameters + ---------------- + compression : 'tiff_deflate', 'tiff_adobe_deflate', 'tiff_lzw', + and other values allowed by LIBTIFF_CORE. + If present, indicates the compression algorithm that + will be passed to the backend to save the image. + """ buf, size = self.print_to_buffer() if kwargs.pop("dryrun", False): return image = Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1) dpi = (self.figure.dpi, self.figure.dpi) - return image.save(filename_or_obj, format='tiff', - dpi=dpi) + #add TIFF compression support by passing the parameter to backend + compression = kwargs.pop("compression", None) + return image.save(filename_or_obj, format='tiff', dpi=dpi, + compression=compression) + print_tiff = print_tif - FigureCanvas = FigureCanvasAgg