Skip to content

Commit 3abd91e

Browse files
author
Daniel Hyams
committed
Straw man commit for making the jpeg quality (when saved by PIL) configurable
via rcParams.
1 parent 14be18e commit 3abd91e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,9 +1930,10 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
19301930
Supported kwargs:
19311931
19321932
*quality*: The image quality, on a scale from 1 (worst) to
1933-
95 (best). The default is 95. Values above 95 should
1934-
be avoided; 100 completely disables the JPEG
1935-
quantization stage.
1933+
95 (best). The default is 95, if not given in the
1934+
matplotlibrc file in the savefig.jpeg_quality parameter.
1935+
Values above 95 should be avoided; 100 completely
1936+
disables the JPEG quantization stage.
19361937
19371938
*optimize*: If present, indicates that the encoder should
19381939
make an extra pass over the image in order to select
@@ -1950,7 +1951,8 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
19501951
options = cbook.restrict_dict(kwargs, ['quality', 'optimize',
19511952
'progressive'])
19521953

1953-
if 'quality' not in options: options['quality'] = 95
1954+
if 'quality' not in options:
1955+
options['quality'] = rcParams.get('savefig.jpeg_quality',95)
19541956

19551957
return image.save(filename_or_obj, format='jpeg', **options)
19561958
print_jpeg = print_jpg

0 commit comments

Comments
 (0)