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
Jpeg quality 95 by default with rendering with PIL #1771
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
05a9d9e
https://github.com/matplotlib/matplotlib/pull/1710
aedb386
Merge remote branch 'original/master'
14be18e
Set default quality for rendering jpegs with PIL to 95.
3abd91e
Straw man commit for making the jpeg quality (when saved by PIL) conf…
e1c2378
Added savefig.jpeg_quality to the rcParams correctly
745da0b
added jpeg quality support for gdk backend
05fc06d
Added jpeg quality support for gtk backend
0a3cb52
Added jpeg quality support for wx backend
56e0c34
bugfix: SetOption for wx.Image takes a string, not an int.
b81bb3d
Two newline fixes to comply with PEP8
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1162,15 +1162,28 @@ def _print_image(self, filename, filetype, *args, **kwargs): | |
gc = renderer.new_gc() | ||
|
||
self.figure.draw(renderer) | ||
|
||
# image is the object that we call SaveFile on. | ||
image = self.bitmap | ||
# set the JPEG quality appropriately. Unfortunately, it is only possible | ||
# to set the quality on a wx.Image object. So if we are saving a JPEG, | ||
# convert the wx.Bitmap to a wx.Image, and set the quality. | ||
if filetype == wx.BITMAP_TYPE_JPEG: | ||
jpeg_quality = kwargs.get('quality',rcParams['savefig.jpeg_quality']) | ||
image = self.bitmap.ConvertToImage() | ||
image.SetOption(wx.IMAGE_OPTION_QUALITY,str(jpeg_quality)) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove newline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean line 1168? |
||
# Now that we have rendered into the bitmap, save it | ||
# to the appropriate file type and clean up | ||
if is_string_like(filename): | ||
if not self.bitmap.SaveFile(filename, filetype): | ||
if not image.SaveFile(filename, filetype): | ||
DEBUG_MSG('print_figure() file save error', 4, self) | ||
raise RuntimeError('Could not save figure to %s\n' % (filename)) | ||
elif is_writable_file_like(filename): | ||
if not self.bitmap.ConvertToImage().SaveStream(filename, filetype): | ||
if not isinstance(image,wx.Image): | ||
image = image.ConvertToImage() | ||
if not image.SaveStream(filename, filetype): | ||
DEBUG_MSG('print_figure() file save error', 4, self) | ||
raise RuntimeError('Could not save figure to %s\n' % (filename)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
PEP8: Please use just one newline between blocks of code.
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.
do you mean between lines 477 and 478?