code: def resize(self, width=None):
          
          (iw, ih) = self.size
          if width is None:
              width = min(iw, utils.term.width)
          elif isinstance(width, basestring):
              percents = dict([(pct, '%s%%' % (pct)) for pct in range(101)])
              width = percents[width]
          height = int(float(ih) * (float(width) / float(iw)))
          height //= 2
          self.img = self.img.resize((width, height))
docs: Resizes image to fit inside terminal
  
          Called by the constructor automatically.