8000 Let dpi be set when saving JPEG using Agg backend by dstansby · Pull Request #9066 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Let dpi be set when saving JPEG using Agg backend #9066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Let dpi be set when saving JPEG using Agg backend
Check that dpi is in options
  • Loading branch information
dstansby committed Aug 23, 2017
commit ff1c8c8ddcc843379d2f15328dacfb6d650aceee
6 changes: 5 additions & 1 deletion lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,13 @@ def print_jpg(self, filename_or_obj, *args, **kwargs):
background = Image.new('RGB', size, color)
background.paste(image, image)
options = {k: kwargs[k]
for k in ['quality', 'optimize', 'progressive']
for k in ['quality', 'optimize', 'progressive', 'dpi']
if k in kwargs}
options.setdefault('quality', rcParams['savefig.jpeg_quality'])
if 'dpi' in options:
# Set the same dpi in both x and y directions
options['dpi'] = (options['dpi'], options['dpi'])

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

Expand Down
0