Skip to content

Correctly handle high dpi in Pillow animation writer. #15691

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 2 commits into from
Nov 14, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 13, 2019

The idea is just to pass self.dpi to savefig() and then use
self.frame_size as the frame size rather than looking up renderer
internals, but this is made easier by properly moving some attributes
and methods (some of __init__, setup, frame_size) from MovieWriter
(which should really be called SubprocessMovieWriter, as that's what
it does) to AbstractMovieWriter, so that PillowWriter can reuse
them without having to carefully prevent any attempt of starting a
subprocess.

Closes #15678, attn @dopplershift.

I... don't understand the doc build failure, likely something with autosummary and inheritance?
Edit: looks like that's indeed the problem, there's already a missing-references entry for PillowWriter.frame_size so I don't feel too bad adding one for MovieWriter.frame_size (now that it's defined in AbstractMovieWriter.frame_size).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

The idea is just to pass self.dpi to savefig() and then use
self.frame_size as the frame size rather than looking up renderer
internals, but this is made easier by properly moving some attributes
and methods (some of `__init__`, `setup`, `frame_size`) from MovieWriter
(which should really be called SubprocessMovieWriter, as that's what
it does) to AbstractMovieWriter, so that PillowWriter can reuse
them without having to carefully prevent any attempt of starting a
subprocess.
Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@timhoffm
Copy link
Member

Not sure about the milestone.

@dopplershift dopplershift added this to the v3.2.0 milestone Nov 14, 2019
@dopplershift
Copy link
Contributor

I'm gonna put it on 3.2 because I think it's low risk and the incorrect behavior was pretty bad.

@dopplershift dopplershift merged commit 6b1d416 into matplotlib:master Nov 14, 2019
@lumberbot-app
Copy link

lumberbot-app bot commented Nov 14, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 6b1d416d03488ead9e8b887e9e5fc9c1145a228b
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #15691: Correctly handle high dpi in Pillow animation writer.'
  1. Push to a named branch :
git push YOURFORK v3.2.x:auto-backport-of-pr-15691-on-v3.2.x
  1. Create a PR against branch v3.2.x, I would have named this PR:

"Backport PR #15691 on branch v3.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@dopplershift
Copy link
Contributor

heh, or maybe not. I don't think this is so important as to need a manual backport, so I'm going to kick to 3.3.

@dopplershift dopplershift modified the milestones: v3.2.0, v3.3.0 Nov 14, 2019
@anntzer anntzer deleted the pillowhighdpianimation branch November 15, 2019 00:01
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.

Error at save animation with pillow
4 participants