Created
March 17, 2022 10:40
-
-
Save reox/eef624d1cbaa3aca5b7443c9cb8807b9 to your computer and use it in GitHub Desktop.
Save a figure as tiff with lzw compression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
# do plotting: | |
#plt.dosomething(...) | |
# pil_kwargs can be used to pass things to PIL. | |
# the save function has **params which then passes the kwargs to the file format save function, for example: | |
# See https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#saving-tiff-images | |
# LZW compression is called tiff_lzw in pil... | |
plt.savefig('foobaz.tiff', pad_inches=0.05, bbox_inches='tight', pil_kwargs=dict(compression='tiff_lzw')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment