From 78ba71476c41b8f579ba7476129bd3e26b4d2169 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Sat, 23 Jun 2012 12:09:17 -0700 Subject: [PATCH] Add detection of file extension for file-like objects --- lib/matplotlib/image.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 52f894bdf93c..a428b46780ba 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -1170,6 +1170,9 @@ def pilread(): if cbook.is_string_like(fname): basename, ext = os.path.splitext(fname) ext = ext.lower()[1:] + elif hasattr(fname, 'name'): + basename, ext = os.path.splitext(fname.name) + ext = ext.lower()[1:] else: ext = 'png' else: