docs: def get_rendition(self, output_scale=1, **kwargs):
          # pylint:disable=too-many-locals
          """
          Get the rendition for this image, generating it if necessary.
          Returns a tuple of `(relative_path, width, height)`, where relative_path
          is relative to the static file directory (i.e. what one would pass into
          `get_static()`)
  
          output_scale -- the upsample factor for the requested rendition
  
          Keyword arguments:
  
          scale -- the downsample factor for the base rendition
          scale_min_width -- the minimum width after downsampling
          scale_min_height -- the minimum height after downsampling
          crop -- box to crop the original image into (left, top, right, bottom)
          width -- the width to target
          height -- the height to target
          max_width -- the maximum width
          max_height -- the maximum height
          resize -- how to fit the width and height; "fit", "fill", or "stretch"
          fill_crop_x -- horizontal offset fraction for resize="fill"
          fill_crop_y -- vertical offset fraction for resize="fill"
          format -- output format
          background -- background color when converting transparent to opaque
          quality -- the JPEG quality to save the image as
          quantize -- how large a palette to use for GIF or PNG images
          """
  
          basename, ext = os.path.splitext(
              os.path.basename(self._record.file_path))
          basename = utils.make_slug(basename)
  
          if kwargs.get('format'):
              ext = '.' + kwargs['format']
  
          # The spec for building the output filename
          out_spec = [basename, self._record.checksum[-10:]]
  
          out_args = {}
          if ext in ['.png', '.jpg', '.jpeg']:
              out_args['optimize'] = True
  
          crop = self._parse_tuple_string(kwargs.get('crop'))
  
          size, box = self.get_rendition_size(kwargs, output_scale, crop)
          box = self._adjust_crop_box(box, crop)
  
          if size and (size[0] < self._record.width or size[1] < self._record.height):
              out_spec.append('x'.join([str(v) for v in size]))
  
          if box:
              # pylint:disable=not-an-iterable
              out_spec.append('-'.join([str(v) for v in box]))
  
          # Set RGBA flattening options
          flatten = self._record.transparent and ext not in ['.png', '.gif']
          if flatten and 'background' in kwargs:
              bg_color = kwargs['background']
              if isinstance(bg_color, (tuple, list)):
                  out_spec.append('b' + '-'.join([str(a) for a in bg_color]))
              else:
                  out_spec.append('b' + str(bg_color))
  
          # Set JPEG quality
          if ext in ('.jpg', '.jpeg') and kwargs.get('quality'):
              out_spec.append('q' + str(kwargs['quality']))
              out_args['quality'] = kwargs['quality']
          if ext in ('.jpg', '.jpeg'):
              out_args['optimize'] = True
  
          # Build the output filename
          out_basename = '_'.join([str(s) for s in out_spec]) + ext
          out_rel_path = os.path.join(
              config.image_output_subdir,
              self._record.checksum[0:2],
              self._record.checksum[2:6],
              out_basename)
          out_fullpath = os.path.join(config.static_folder, out_rel_path)
  
          if os.path.isfile(out_fullpath):
              os.utime(out_fullpath)
              return utils.static_url(out_rel_path, kwargs.get('absolute')), size
  
          LocalImage.thread_pool().submit(
              self._render, out_fullpath, size, box, flatten, kwargs, out_args)
  
          return flask.url_for('async', filename=out_rel_path, _external=kwargs.get('absolute')), size