Revision: 6285
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6285&view=rev
Author: jdh2358
Date: 2008-10-20 20:54:24 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
added image thumbnail example
Added Paths:
-----------
trunk/matplotlib/examples/misc/image_thumbnail.py
Added: trunk/matplotlib/examples/misc/image_thumbnail.py
===================================================================
--- trunk/matplotlib/examples/misc/image_thumbnail.py
(rev 0)
+++ trunk/matplotlib/examples/misc/image_thumbnail.py 2008-10-20 20:54:24 UTC
(rev 6285)
@@ -0,0 +1,29 @@
+"""
+You can use matplotlib to generate thumbnails from existing images.
+matplotlib natively supports PNG files on the input side, and other
+image types transparently if your have PIL installed
+"""
+
+# build thumbnails of all images in a directory
+import sys, os, glob
+import matplotlib.image as image
+
+
+if len(sys.argv)!=2:
+ print 'Usage: python %s IMAGEDIR'%__file__
+ raise SystemExit
+indir = sys.argv[1]
+if not os.path.exists(indir):
+ print 'Could not find input directory "%s"'%indir
+ raise SystemExit
+
+outdir = 'thumbs'
+if not os.path.exists(outdir):
+ os.makedirs(outdir)
+
+for fname in glob.glob(os.path.join(indir, '*.png')):
+ basedir, basename = os.path.split(fname)
+ outfile = os.path.join(outdir, basename)
+ fig = image.thumbnail(fname, outfile, scale=0.15)
+ print 'saved thumbnail of %s to %s'%(fname, outfile)
+
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins