docs: def _as_rescale(self, get, targetbitdepth):
          """Helper used by :meth:`asRGB8` and :meth:`asRGBA8`."""
          width, height, pixels, meta = get()
          maxval = 2**meta['bitdepth'] - 1
          targetmaxval = 2**targetbitdepth - 1
          factor = float(targetmaxval) / float(maxval)
          meta['bitdepth'] = targetbitdepth
  
          def iterscale(rows):
              for row in rows:
                  yield array('BH'[targetbitdepth > 8],
                              [int(round(x * factor)) for x in row])
          if maxval == targetmaxval:
              return width, height, pixels, meta
          else:
              if 'transparent' in meta:
                  transparent = meta['transparent']
                  if isinstance(transparent, tuple):
                      transparent = tuple(list(
                                          iterscale((transparent,))
                                          )[0])
                  else:
                      transparent = tuple(list(
                                          iterscale(((transparent,),))
                                          )[0])[0]
                  meta['transparent'] = transparent
              return width, height, iterscale(pixels), meta