def cropbox(self, image, geometry, options): """ Wrapper for ``_cropbox`` """ cropbox = options['cropbox'] if not cropbox: return image x, y, x2, y2 = parse_cropbox(cropbox) return self._cropbox(image, x, y, x2, y2)
def get_image_ratio(self, image, options): """ Calculates the image ratio. If cropbox option is used, the ratio may have changed. """ cropbox = options['cropbox'] if cropbox: x, y, x2, y2 = parse_cropbox(cropbox) x = x2 - x y = y2 - y else: x, y = self.get_image_size(image) return float(x) / y