class_docstr: Converter for images
class_docstr_tok: ["Converter","for","images"]
docstr: Stretch image to fit new size, keeping the aspect ratio.
docstr_tok: ["Stretch","image","to","fit","new","size",",","keeping","the","aspect","ratio","."]
code: def _resize_larger_keep_aspect_ratio(self):
      """Stretch image to fit new size, keeping the aspect ratio."""
      orig_w, orig_h = self._orig_img.size
  
      # Find min stretch ratio, create a scaled up image.
      resize_ratio = min(
          self._desired_size[0] / orig_w, self._desired_size[1] / orig_h
      )
      (new_width, new_height) = (
          int(round(orig_h * resize_ratio)),
          int(round(orig_w * resize_ratio)),
      )
      new_img = ImageOps.fit(
          image=self._orig_img, size=(new_width, new_height)
      )
  
      # If after stretching, it's the desired size already, then return image.
      if self._desired_size == (new_width, new_height):
          return new_img
  
      # Otherwise we need to pad it to the correct size.
      offset = (
          int(round((self._desired_size[0] - new_width) / 2)),
          int(round((self._desired_size[1] - new_height) / 2)),
      )
      bkgd_img = Image.new(
          self._bg_mode, self._desired_size, self._bg_color
      )
      bkgd_img.paste(new_img, offset)
      return bkgd_img
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import logging
  from PIL import Image
  from PIL import ImageOps
label_desc: Use image node_id 7 for calling the ImageConverter obj's underlying member method code with example usage: obj._resize_larger_keep_aspect_ratio() and returns: bkgd_img, new_img