def trim(self): is_gifsicle = (self.context.request.engine.extension == '.gif' and self.context.config.USE_GIFSICLE_ENGINE) if self.context.request.trim is None or not trim_enabled or is_gifsicle: return mode, data = self.engine.image_data_as_rgb() box = _bounding_box.apply( mode, self.engine.size[0], self.engine.size[1], self.context.request.trim_pos, self.context.request.trim_tolerance, data ) if box[2] < box[0] or box[3] < box[1]: logger.warn("Ignoring trim, there wouldn't be any image left, check the tolerance.") return self.engine.crop(box[0], box[1], box[2] + 1, box[3] + 1) if self.context.request.should_crop: self.context.request.crop['left'] -= box[0] self.context.request.crop['top'] -= box[1] self.context.request.crop['right'] -= box[0] self.context.request.crop['bottom'] -= box[1]
async def trim(self): is_gifsicle = (self.context.request.engine.extension == ".gif" and self.context.config.USE_GIFSICLE_ENGINE) if (self.context.request.trim is None or not TRIM_ENABLED or is_gifsicle): return mode, data = self.engine.image_data_as_rgb() box = _bounding_box.apply( mode, self.engine.size[0], self.engine.size[1], self.context.request.trim_pos, self.context.request.trim_tolerance, data, ) if box[2] < box[0] or box[3] < box[1]: logger.warning("Ignoring trim, there wouldn't be any image " "left, check the tolerance.") return self.engine.crop(box[0], box[1], box[2] + 1, box[3] + 1) if self.context.request.should_crop: self.context.request.crop["left"] -= box[0] self.context.request.crop["top"] -= box[1] self.context.request.crop["right"] -= box[0] self.context.request.crop["bottom"] -= box[1]
def trim(self): if self.context.request.trim is None or not trim_enabled: return box = _bounding_box.apply(self.engine.get_image_mode(), self.engine.size[0], self.engine.size[1], self.context.request.trim_pos, self.context.request.trim_tolerance, self.engine.get_image_data()) if box[2] < box[0] or box[3] < box[1]: logger.warn("Ignoring trim, there wouldn't be any image left, check the tolerance.") return self.engine.crop(box[0], box[1], box[2] + 1, box[3] + 1) if self.context.request.should_crop: self.context.request.crop['left'] -= box[0] self.context.request.crop['top'] -= box[1] self.context.request.crop['right'] -= box[0] self.context.request.crop['bottom'] -= box[1]
def trim(self): if self.context.request.trim is None or not trim_enabled: return box = _bounding_box.apply(self.engine.get_image_mode(), self.engine.size[0], self.engine.size[1], self.context.request.trim_pos, self.context.request.trim_tolerance, self.engine.get_image_data()) if box[2] < box[0] or box[3] < box[1]: logger.warn( "Ignoring trim, there wouldn't be any image left, check the tolerance." ) return self.engine.crop(box[0], box[1], box[2] + 1, box[3] + 1) if self.context.request.should_crop: self.context.request.crop['left'] -= box[0] self.context.request.crop['top'] -= box[1] self.context.request.crop['right'] -= box[0] self.context.request.crop['bottom'] -= box[1]