10000 Jpeg quality 95 by default with rendering with PIL by dhyams · Pull Request #1771 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Jpeg quality 95 by default with rendering with PIL #1771

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 10 commits into from
Apr 23, 2013
Prev Previous commit
Next Next commit
added jpeg quality support for gdk backend
  • Loading branch information
Daniel Hyams committed Apr 19, 2013
commit 745da0b57df24d03a2fb77b2b81dcedf9e993b5c
12 changes: 11 additions & 1 deletion lib/matplotlib/backends/backend_gdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name
import numpy as np

import matplotlib
from matplotlib import rcParams
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
FigureManagerBase, FigureCanvasBase
Expand Down Expand Up @@ -471,4 +472,13 @@ def _print_image(self, filename, format, *args, **kwargs):
pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
0, 0, 0, 0, width, height)

pixbuf.save(filename, format)
# set the default quality, if we are writing a JPEG.
# http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
options = cbook.restrict_dict(kwargs, ['quality'])
if format in ['jpg','jpeg']:
if 'quality' not in options:
options['quality'] = rcParams['savefig.jpeg_quality']
options['quality'] = str(options['quality'])

pixbuf.save(filename, format, options=options)

0