Revision: 5252
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5252&view=rev
Author:   jdh2358
Date:     2008-05-24 10:55:54 -0700 (Sat, 24 May 2008)

Log Message:
-----------
fixed a wx bug and added PIL support to imread

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
    trunk/matplotlib/lib/matplotlib/image.py
    trunk/matplotlib/lib/matplotlib/patches.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-05-24 07:43:13 UTC (rev 5251)
+++ trunk/matplotlib/CHANGELOG  2008-05-24 17:55:54 UTC (rev 5252)
@@ -1,3 +1,6 @@
+2008-05-24 Added PIL support for loading images to imread (if PIL is
+           available) - JDH
+
 2008-05-23 Provided a function and a method for controlling the
            plot color cycle. - EF
 

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-05-24 
07:43:13 UTC (rev 5251)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-05-24 
17:55:54 UTC (rev 5252)
@@ -1234,7 +1234,7 @@
         statbar = StatusBarWx(self)
         self.SetStatusBar(statbar)
         self.canvas = self.get_canvas(fig)
-        self.canvas.SetInitialSize(wx.Size(fig.bbox.width(), 
fig.bbox.height()))
+        self.canvas.SetInitialSize(wx.Size(fig.bbox.width, fig.bbox.height))
         self.sizer =wx.BoxSizer(wx.VERTICAL)
         self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND)
         # By adding toolbar in sizer, we are able to put it at the bottom

Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py    2008-05-24 07:43:13 UTC (rev 
5251)
+++ trunk/matplotlib/lib/matplotlib/image.py    2008-05-24 17:55:54 UTC (rev 
5252)
@@ -652,13 +652,29 @@
 
     Return value is a MxNx4 array of 0-1 normalized floats
 
+    matplotlib can only read PNGs natively, but if PIL is installed,
+    it will use it to load the image and return an RGBA if possible
+    which can be used with imshow
     """
+
+    def pilread():
+        'try to load the image with PIL or return None'
+        try: import Image
+        except ImportError: return None
+        image = Image.open( fname )
+        return pil_to_array(image)
+
+
     handlers = {'png' :_image.readpng,
                 }
     basename, ext = os.path.splitext(fname)
     ext = ext.lower()[1:]
+
     if ext not in handlers.keys():
-        raise ValueError('Only know how to handled extensions: %s' % 
handlers.keys())
+        im = pilread()
+        if im is None:
+            raise ValueError('Only know how to handle extensions: %s; with PIL 
installed matplotlib can handle more images' % handlers.keys())
+        return im
 
     handler = handlers[ext]
     return handler(fname)

Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py  2008-05-24 07:43:13 UTC (rev 
5251)
+++ trunk/matplotlib/lib/matplotlib/patches.py  2008-05-24 17:55:54 UTC (rev 
5252)
@@ -11,8 +11,8 @@
 from matplotlib.path import Path
 
 # these are not available for the object inspector until after the
-# class is build so we define an initial set here for the init
-# function and they will be overridden after object defn
+# class is built so we define an initial set here for the init
+# function and they will be overridden after object definition
 artist.kwdocd['Patch'] = """\
           alpha: float
           animated: [True | False]
@@ -31,7 +31,6 @@
           visible: [True | False]
           zorder: any number
           """
-
 class Patch(artist.Artist):
     """
     A patch is a 2D thingy with a face color and an edge color
@@ -1109,7 +1108,6 @@
     r.draw(renderer)
 
 artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch)
-
 for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow',
           'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse'):
     artist.kwdocd[k] = patchdoc


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to