title: How do I make PIL take into account the shortest side when creating a thumbnail?
body: <p>Currently, for my function below...the image will be resized based on the longest side.</p>
  
  <p>Basically the image has a larger height, the height will be 200px. The width will be just...whatever...</p>
  
  <p>If the image has a larger width, the width will be 200px, and the height will adjust accordingly.  </p>
  
  <p>How do I flip this around!? I want this function to take into account the shortest side.  </p>
  
  <p><strong>Am I writing this function incorrectly??</strong></p>
  
  <pre><code>def create_thumbnail(f, width=200, height=None, pad = False):
      #resizes the longest side!!! doesn't even care about the shortest side
      #this function maintains aspect ratio.
      if height==None: height=width
      im = Image.open(StringIO(f))
      imagex = int(im.size[0])
      imagey = int(im.size[1])
      if imagex &lt; width or imagey &lt; height:
          pass
          #return None
      if im.mode not in ('L', 'RGB', 'RGBA'):
          im = im.convert('RGB')
      im.thumbnail((width, height), Image.ANTIALIAS)
      thumbnail_file = StringIO()
      im.save(thumbnail_file, 'JPEG')
      thumbnail_file.seek(0)
      return thumbnail_file
  </code></pre>