0

I want to use motion blur with ImageMagick. Motion blur in ImageMagick documentation.

But in Wand there is only gaussian_blur. Gaussian blur in Wand documentation.

Is motion blur missing in wand?

crg__
  • 11
  • 1

1 Answers1

1

Is motion blur missing in wand?

Yes, as of 0.4.3 there is no wand.image.Image.motion_blur method implemented on library.

You'll need to extend wand's API to include MagickMotionBlurImage.

import ctypes
from wand.image import Image
from wand.api import library

# Tell Python about the C method
library.MagickMotionBlurImage.argtypes = (ctypes.c_void_p,  # wand
                                          ctypes.c_double,  # radius
                                          ctypes.c_double,  # sigma
                                          ctypes.c_double)  # angle

# Extend wand.image.Image class to include method signature (remember error handling)
class MyImage(Image):
    def motion_blur(self, radius=0.0, sigma=0.0, angle=0.0):
        library.MagickMotionBlurImage(self.wand,
                                      radius,
                                      sigma,
                                      angle)


# Example usage
with MyImage(filename='rose:') as img:
    img.motion_blur(radius=8.0, sigma=4.0, angle=-57.0)
    img.save(filename='rose_motion.png')

enter image description here

emcconville
  • 23,800
  • 4
  • 50
  • 66