def check_in_image(paste_image_location, paste_image_size, canvas_image_size):
  """Checks whether the location for the pasted image is within the canvas.

  Args:
    paste_image_location: a namedtuple of utils.XY, with 'x' and 'y' coordinates
      of
      the center of the image we want to paste.
    paste_image_size: a namedtuple of utils.XY, with 'x' and 'y' coordinates
      corresponding to the size of the image we are pasting.
    canvas_image_size: the size of the canvas that we are pasting the image to.
  Returns:
    True if the pasted image would lie within the canvas, False otherwise.
  """
  offset_x = int(paste_image_size.x / 2) + 1
  offset_y = int(paste_image_size.y / 2) + 1

  if (paste_image_location.x + offset_x > canvas_image_size or
      paste_image_location.x - offset_x < 1 or
      paste_image_location.y + offset_y > canvas_image_size or
      paste_image_location.y - offset_y < 1):
    return False
  return True