code: def get_resized_size(self):
          
          f = self.fmt
          iw, ih = self.image.size
  
          if not f.stretch and iw <= self.fw and ih <= self.fh:
              return
  
          if self.image_ratio == self.format_ratio:
              # same ratio, just resize
              return (self.fw, self.fh)
  
          elif self.image_ratio < self.format_ratio:
              # image taller than format
              return (self.fh * iw / ih, self.fh)
  
          else: # self.image_ratio > self.format_ratio
              # image wider than format
              return (self.fw, self.fw * ih / iw)
docs: Get target size for the stretched or shirnked image to fit within the
          target dimensions. Do not stretch images if not format.stretch.
  
          Note that this method is designed to operate on already cropped image.