예제 #1
0
    def _crop(self, fieldname, scale, box):
        """switch between dexterity and Archetypes
        """
        croputils = IImageCroppingUtils(self.context)
        data = croputils.get_image_data(fieldname)

        original_file = StringIO(data)
        image = PIL.Image.open(original_file)
        image_format = image.format or self.DEFAULT_FORMAT

        cropped_image = image.crop(box)
        cropped_image_file = StringIO()
        cropped_image.save(cropped_image_file, image_format, quality=100)
        cropped_image_file.seek(0)

        croputils.save_cropped(fieldname, scale, cropped_image_file)

        # store crop information in annotations
        self._store(fieldname, scale, box)
예제 #2
0
    def _crop(self, fieldname, scale, box, interface=None):
        """switch between dexterity and Archetypes
        """
        croputils = IImageCroppingUtils(self.context)
        field = croputils.get_image_field(fieldname)
        data = croputils.get_image_data(fieldname)

        original_file = StringIO(data)
        image = PIL.Image.open(original_file)
        image_format = image.format or self.DEFAULT_FORMAT

        cropped_image = image.crop(box)
        cropped_image_file = StringIO()
        cropped_image.save(cropped_image_file, image_format, quality=100)
        cropped_image_file.seek(0)

        croputils.save_cropped(fieldname, field, scale, cropped_image_file,
                               interface)

        # store crop information in annotations
        self._store(fieldname, scale, box)
예제 #3
0
    def _crop(self, fieldname, scale, box):
        """Delegate to store.

        """
        storage = Storage(self.context)
        storage.store(fieldname, scale, box)

        if IImageCroppingDX.providedBy(self.context):
            return
        # AT BBB scaling.
        croputils = IImageCroppingUtils(self.context)
        data = croputils.get_image_data(fieldname)

        original_file = BytesIO(data)
        image = PIL.Image.open(original_file)
        image_format = image.format or self.DEFAULT_FORMAT

        cropped_image = image.crop(box)
        cropped_image_file = BytesIO()
        cropped_image.save(cropped_image_file, image_format, quality=100)
        cropped_image_file.seek(0)

        croputils.save_cropped(fieldname, scale, cropped_image_file)