2016-07-23 31 views

回答

1

魔杖中是否缺少運動模糊?

是,作爲0.4.3有上庫中實現無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') 

enter image description here