code: def thumbnail_image(realfile, filename, size=(200, 75), suffix=True, quality=None):
      
      from PIL import Image
  
      im = Image.open(realfile)
      file, ext = os.path.splitext(realfile)
      if im.size[0]<=size[0] and im.size[1]<=size[1]:
          #the image size is smaller than thumbnail size, so we don't need to 
          #thumbnail the image
          return filename, filename
      im.thumbnail(size, Image.ANTIALIAS)
      format = ext[1:].upper()
      if format == 'JPG':
          format = 'JPEG'
      if suffix:
          ofile = file + ".thumbnail" + ext
      else:
          ofile = realfile
      im.save(ofile, format, quality=quality or QUALITY)
      file1, ext1 = os.path.splitext(filename)
      if suffix:
          ofile1 = file1 + ".thumbnail" + ext
      else:
          ofile1 = filename
      return ofile, ofile1
docs: :param: real input filename (string)
      :filename: relative input filename (string)
      :param: suffix if True, then add '.thumbnail' to the end of filename
      
      return value should be a tuple, (saved_real_filename, saved_filename)