[英]How to motion blur with ImageMagick using wand?
I want to use motion blur with ImageMagick. 我想将运动模糊与ImageMagick一起使用。 Motion blur in ImageMagick documentation.
ImageMagick文档中的运动模糊。
But in Wand there is only gaussian_blur. 但是在魔杖中只有gaussian_blur。 Gaussian blur in Wand documentation.
魔杖文档中的高斯模糊。
Is motion blur missing in wand? 魔杖中缺少运动模糊吗?
Is motion blur missing in wand?
魔杖中缺少运动模糊吗?
Yes, as of 0.4.3 there is no wand.image.Image.motion_blur
method implemented on wand library. 是的,从0.4.3版本开始 ,在魔杖库上没有实现
wand.image.Image.motion_blur
方法。
You'll need to extend wand's API to include MagickMotionBlurImage
. 您需要扩展wand的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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.