Adding more image format support...

We've had some requests from internal users here at STScI to make it easier to save JPEG files directly from matplotlib. We currently support JPEG saving from the Gtk* and Wx* backends (because those libraries come with JPEG saving support), but not in the Tk backend that most of our users use.

One solution to this may be to add an optional dependency on PIL, and if found save JPEG files (and maybe some of the other esoteric formats PIL supports). The work done a couple of years back to manage the supported file types should make this pretty easy.

While adding a hard dependency on PIL is probably not a good idea, are there any objections to making it a soft dependency?

Mike

···

--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

None here, especially when the alternative is writing our own bindings
to the jpeg library.

Ryan

···

On Tue, Jul 6, 2010 at 2:07 PM, Michael Droettboom <mdroe@...31...> wrote:

We've had some requests from internal users here at STScI to make it
easier to save JPEG files directly from matplotlib. We currently
support JPEG saving from the Gtk* and Wx* backends (because those
libraries come with JPEG saving support), but not in the Tk backend that
most of our users use.

One solution to this may be to add an optional dependency on PIL, and if
found save JPEG files (and maybe some of the other esoteric formats PIL
supports). The work done a couple of years back to manage the supported
file types should make this pretty easy.

While adding a hard dependency on PIL is probably not a good idea, are
there any objections to making it a soft dependency?

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

No objections from me -- we already optionally use it in imread.

JDH

···

On Tue, Jul 6, 2010 at 2:07 PM, Michael Droettboom <mdroe@...31...> wrote:

We've had some requests from internal users here at STScI to make it
easier to save JPEG files directly from matplotlib. We currently
support JPEG saving from the Gtk* and Wx* backends (because those
libraries come with JPEG saving support), but not in the Tk backend that
most of our users use.

One solution to this may be to add an optional dependency on PIL, and if
found save JPEG files (and maybe some of the other esoteric formats PIL
supports). The work done a couple of years back to manage the supported
file types should make this pretty easy.

While adding a hard dependency on PIL is probably not a good idea, are
there any objections to making it a soft dependency?

2010/7/6 Michael Droettboom <mdroe@...31...>:

One solution to this may be to add an optional dependency on PIL, and if
found save JPEG files (and maybe some of the other esoteric formats PIL
supports). The work done a couple of years back to manage the supported
file types should make this pretty easy.

I wrote a backend for PIL, if there is interest, I can show the code.
But it's just so easy, and maybe I'm just interfering with the pyplot
internals, so fwiw.

Friedrich

Thanks for the offer. In the meantime, I committed something myself for this. (I should have written back to the list, sorry...)

I'd still be interested in seeing your patch in case there's something extra or better in it that mine doesn't do.

Mike

···

On 07/07/2010 02:43 PM, Friedrich Romstedt wrote:

2010/7/6 Michael Droettboom<mdroe@...31...>:
   

One solution to this may be to add an optional dependency on PIL, and if
found save JPEG files (and maybe some of the other esoteric formats PIL
supports). The work done a couple of years back to manage the supported
file types should make this pretty easy.
     

I wrote a backend for PIL, if there is interest, I can show the code.
But it's just so easy, and maybe I'm just interfering with the pyplot
internals, so fwiw.

Friedrich
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

2010/7/7 Michael Droettboom <mdroe@...31...>:

Thanks for the offer. In the meantime, I committed something myself for
this. (I should have written back to the list, sorry...)

I'd still be interested in seeing your patch in case there's something extra
or better in it that mine doesn't do.

Ok, nice, here it is. I'd be interested in your approach if it differs.

Friedrich

canvas.py (2.02 KB)