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

Conversation

dstansby
Copy link
Member

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.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Aug 21, 2017

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'])
Copy link
Member

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)?

Copy link
Member

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

@tacaswell
Copy link
Member

Does pillow provide access to a way to access the meta-data?

Maybe use exiv2 in a subprocess to query the dpi?

@tacaswell
Copy link
Member

@dstansby This seems to need a rebase.

@tacaswell
Copy link
Member

Conflict is from #9071

@WeatherGod WeatherGod merged commit 24817d5 into matplotlib:master Aug 25, 2017
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)
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0