def conditional_sharpen(
            self,
            amount,
            radius,
            luminance_only,
            resize_ratio_threshold):

        width, height = self.engine.size
        try:
            original_width = self.context.request.source_width
        except AttributeError:
            original_width = self.engine.source_width

        try:
            original_height = self.context.request.source_height
        except AttributeError:
            original_height = self.engine.source_height

        mode, data = self.engine.image_data_as_rgb()
        source_sum = float(original_width + original_height)
        destination_sum = float(width + height)
        resize_ratio = destination_sum / source_sum

        if resize_ratio < resize_ratio_threshold:
            imgdata = _sharpen.apply(
                mode, width, height, amount, radius,
                luminance_only, data
            )
            self.engine.set_image_data(imgdata)
Exemplo n.º 2
0
 def sharpen(self, amount, radius, luminance_only):
     width, height = self.engine.size
     imgdata = _sharpen.apply(
         self.engine.get_image_mode(), width, height, amount, radius,
         luminance_only, self.engine.get_image_data()
     )
     self.engine.set_image_data(imgdata)
Exemplo n.º 3
0
 def sharpen(self, amount, radius, luminance_only):
     width, height = self.engine.size
     mode, data = self.engine.image_data_as_rgb()
     imgdata = _sharpen.apply(
         mode, width, height, amount, radius,
         luminance_only, data
     )
     self.engine.set_image_data(imgdata)
Exemplo n.º 4
0
 def sharpen(self, amount, radius, luminance_only):
     width, height = self.engine.size
     mode, data = self.engine.image_data_as_rgb()
     imgdata = _sharpen.apply(
         mode.encode('utf-8'), width, height, amount, radius,
         luminance_only, data
     )
     self.engine.set_image_data(imgdata)