def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear', preview=False):
 (basedir, basename) = os.path.split(infile)
 (baseout, extout) = os.path.splitext(thumbfile)
 im = imread(infile)
 (rows, cols, depth) = im.shape
 dpi = 100
 height = ((float(rows) / dpi) * scale)
 width = ((float(cols) / dpi) * scale)
 extension = extout.lower()
 if preview:
  import matplotlib.pyplot as plt
  fig = plt.figure(figsize=(width, height), dpi=dpi)
 else:
  if (extension == '.png'):
   from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
  elif (extension == '.pdf'):
   from matplotlib.backends.backend_pdf import FigureCanvasPDF as FigureCanvas
  elif (extension == '.svg'):
   from matplotlib.backends.backend_svg import FigureCanvasSVG as FigureCanvas
  else:
   raise ValueError("Can only handle extensions 'png', 'svg' or 'pdf'")
  from matplotlib.figure import Figure
  fig = Figure(figsize=(width, height), dpi=dpi)
  canvas = FigureCanvas(fig)
 ax = fig.add_axes([0, 0, 1, 1], aspect='auto', frameon=False, xticks=[], yticks=[])
 (basename, ext) = os.path.splitext(basename)
 ax.imshow(im, aspect='auto', resample=True, interpolation='bilinear')
 fig.savefig(thumbfile, dpi=dpi)
 return fig

def thumbnail ( infile , thumbfile , scale = 0.1 , interpolation = 'bilinear' , preview = False ) : ( basedir , basename ) = os . path . split ( infile ) ( baseout , extout ) = os . path . splitext ( thumbfile ) im = imread ( infile ) ( rows , cols , depth ) = im . shape dpi = 100 height = ( ( float ( rows ) / dpi ) * scale ) width = ( ( float ( cols ) / dpi ) * scale ) extension = extout . lower ( ) if preview : import matplotlib . pyplot as plt fig = plt . figure ( figsize = ( width , height ) , dpi = dpi ) else : if ( extension == '.png' ) : from matplotlib . backends . backend_agg import FigureCanvasAgg as FigureCanvas elif ( extension == '.pdf' ) : from matplotlib . backends . backend_pdf import FigureCanvasPDF as FigureCanvas elif ( extension == '.svg' ) : from matplotlib . backends . backend_svg import FigureCanvasSVG as FigureCanvas else : raise ValueError ( "Can only handle extensions 'png', 'svg' or 'pdf'" ) from matplotlib . figure import Figure fig = Figure ( figsize = ( width , height ) , dpi = dpi ) canvas = FigureCanvas ( fig ) ax = fig . add_axes ( [ 0 , 0 , 1 , 1 ] , aspect = 'auto' , frameon = False , xticks = [ ] , yticks = [ ] ) ( basename , ext ) = os . path . splitext ( basename ) ax . imshow ( im , aspect = 'auto' , resample = True , interpolation = 'bilinear' ) fig . savefig ( thumbfile , dpi = dpi ) return fig
proxy to solrs get_thumbnail .