docs: def region_to_apply(self):
          """Return the x,y,w,h parameters to extract given image width and height.
  
          Assume image width and height are available in self.width and
          self.height, and self.request is IIIFRequest object
  
          Expected use:
            (x,y,w,h) = self.region_to_apply()
            if (x is None):
                # full image
            else:
                # extract
  
          Returns (None,None,None,None) if no extraction is required.
          """
          if (self.request.region_full or
              (self.request.region_pct and
               self.request.region_xywh == (0, 0, 100, 100))):
              return(None, None, None, None)
          # Cannot do anything else unless we know size (in self.width and
          # self.height)
          if (self.width <= 0 or self.height <= 0):
              raise IIIFError(code=501, parameter='region',
                              text="Region parameters require knowledge of image size which is not implemented.")
          if (self.request.region_square):
              if (self.width <= self.height):
                  y_offset = (self.height - self.width) / 2
                  return(0, y_offset, self.width, self.width)
              else:  # self.width>self.height
                  x_offset = (self.width - self.height) / 2
                  return(x_offset, 0, self.height, self.height)
          # pct or explicit pixel sizes
          pct = self.request.region_pct
          (x, y, w, h) = self.request.region_xywh
          # Convert pct to pixels based on actual size
          if (pct):
              x = int((x / 100.0) * self.width + 0.5)
              y = int((y / 100.0) * self.height + 0.5)
              w = int((w / 100.0) * self.width + 0.5)
              h = int((h / 100.0) * self.height + 0.5)
          # Check if boundary extends beyond image and truncate
          if ((x + w) > self.width):
              w = self.width - x
          if ((y + h) > self.height):
              h = self.height - y
          # Final check to see if we have the whole image
          if (w == 0 or h == 0):
              raise IIIFZeroSizeError(code=400, parameter='region',
                                      text="Region parameters would result in zero size result image.")
          if (x == 0 and y == 0 and w == self.width and h == self.height):
              return(None, None, None, None)
          return(x, y, w, h)