8000 Let dpi be set when saving JPEG using Agg backend · matplotlib/matplotlib@0dd3e99 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0dd3e99

Browse files
committed
Let dpi be set when saving JPEG using Agg backend
Check that dpi is in options
1 parent 225a4a0 commit 0dd3e99

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/backends/backend_agg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
568568
background = Image.new('RGB', size, color)
569569
background.paste(image, image)
570570
options = restrict_dict(kwargs, ['quality', 'optimize',
571-
'progressive'])
571+
'progressive', 'dpi'])
572572

573573
if 'quality' not in options:
574574
options['quality'] = rcParams['savefig.jpeg_quality']
575+
if 'dpi' in options:
576+
# Set the same dpi in both x and y directions
577+
options['dpi'] = (options['dpi'], options['dpi'])
575578

576579
return background.save(filename_or_obj, format='jpeg', **options)
577580
print_jpeg = print_jpg

0 commit comments

Comments
 (0)
0