Ejemplo n.º 1
0
    def auto_orient(self):
        image = self.image

        if image.orientation not in ['top_left', 'undefined']:
            image = image.clone()
            if hasattr(image, 'auto_orient'):
                # Wand 0.4.1 +
                image.auto_orient()
            else:
                orientation_ops = {
                    'top_right': [image.flop],
                    'bottom_right':
                    [functools.partial(image.rotate, degree=180.0)],
                    'bottom_left': [image.flip],
                    'left_top':
                    [image.flip,
                     functools.partial(image.rotate, degree=90.0)],
                    'right_top':
                    [functools.partial(image.rotate, degree=90.0)],
                    'right_bottom':
                    [image.flop,
                     functools.partial(image.rotate, degree=90.0)],
                    'left_bottom':
                    [functools.partial(image.rotate, degree=270.0)]
                }
                fns = orientation_ops.get(image.orientation)

                if fns:
                    for fn in fns:
                        fn()

                    image.orientation = 'top_left'

        return WandImage(image)
Ejemplo n.º 2
0
    def auto_orient(self):
        image = self.image

        if image.orientation not in ['top_left', 'undefined']:
            image = image.clone()
            if hasattr(image, 'auto_orient'):
                # Wand 0.4.1 +
                image.auto_orient()
            else:
                orientation_ops = {
                    'top_right': [image.flop],
                    'bottom_right': [functools.partial(image.rotate, degree=180.0)],
                    'bottom_left': [image.flip],
                    'left_top': [image.flip, functools.partial(image.rotate, degree=90.0)],
                    'right_top': [functools.partial(image.rotate, degree=90.0)],
                    'right_bottom': [image.flop, functools.partial(image.rotate, degree=90.0)],
                    'left_bottom': [functools.partial(image.rotate, degree=270.0)]
                }
                fns = orientation_ops.get(image.orientation)

                if fns:
                    for fn in fns:
                        fn()

                    image.orientation = 'top_left'

        return WandImage(image)