-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
|
||
if 'quality' not in options: | ||
options['quality'] = rcParams['savefig.jpeg_quality'] | ||
# Set the same dpi in both x and y directions | ||
options['dpi'] = (options['dpi'], options['dpi']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the dpi wasn't set from the options, should it fetch it from the rcparams? (or does that already happen in building kwargs)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably better to be defensive about it if 'dpi' in options
Does pillow provide access to a way to access the meta-data? Maybe use |
@dstansby This seems to need a rebase. |
Conflict is from #9071 |
Check that dpi is in options
plt.plot([0, 1, 2], [0, 1, 0]) | ||
plt.savefig('test.jpg', dpi=200) | ||
im = Image.open("test.jpg") | ||
assert im.info['dpi'] == (200, 200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should delete test.jpg after it is done (or, more simply, just write the file to a bytesio).
Partially fixes (for the Agg backend) #9035. Not sure if there's a test I can put in, but I have checked that preview on macOS reports the correct dpi when I manually change the dpi.