code: def resize(fname, basewidth, opFilename):
      
      if basewidth == 0:
          basewidth = 300
      img = Image.open(fname)
      wpercent = (basewidth/float(img.size[0]))
      hsize = int((float(img.size[1])*float(wpercent)))
      img = img.resize((basewidth,hsize), Image.ANTIALIAS)
      img.save(opFilename)
docs: resize an image to basewidth