Given an image, scales the image down (or up, if ``upscale`` equates
        to a boolean ``True``).

        :param Image image: This is your engine's ``Image`` object. For
            PIL it's PIL.Image.
        :param tuple geometry: Geometry of the image in the format of (x,y).
        :returns: The scaled image. The returned type depends on your
            choice of Engine.

def scale(self, image, geometry, upscale, crop):
        """
        Given an image, scales the image down (or up, if ``upscale`` equates
        to a boolean ``True``).

        :param Image image: This is your engine's ``Image`` object. For
            PIL it's PIL.Image.
        :param tuple geometry: Geometry of the image in the format of (x,y).
        :returns: The scaled image. The returned type depends on your
            choice of Engine.
        """
        x_image, y_image = map(float, self.get_image_size(image))

        # Calculate scaling factor.
        factors = (geometry[0] / x_image, geometry[1] / y_image)
        factor = max(factors) if crop else min(factors)
        if factor < 1 or upscale:
            width = toint(x_image * factor)
            height = toint(y_image * factor)
            image = self._scale(image, width, height)

        return image