我想在ImageMagick中使用运动模糊。 Motion blur in ImageMagick documentation.
但在Wand中只有gaussian_blur。 Gaussian blur in Wand documentation.
魔杖中是否缺少运动模糊?
答案 0 :(得分:1)
魔杖中是否缺少运动模糊?
是的,从 0.4.3 开始,wand库上没有实现wand.image.Image.motion_blur
方法。
您需要扩展魔杖的API以包含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')