Wand中的相框功能在Mac上不起作用?

时间:2019-07-30 15:35:47

标签: python macos frame wand

我正在尝试使用Python魔杖中的image.frame函数在图像周围添加边框:

image.frame(width=2, height=2)

这在Raspberry Pi上似乎可以正常工作,但是在Mac上可以将图像转换为灰度。有什么线索吗?

from wand.image include *
from wand.display include *

#  tryme.jpg is color jpg image
image=Image(filename="tryme.jpg")
image.frame(width=2, height=2)

display(image)

应显示周围有2个像素边框的彩色图片。

1 个答案:

答案 0 :(得分:1)

这对于使用Python Wand 0.5.5在ImageMagick 6.9.10.57 Q16 Mac OSX Sierra上的我来说很好用。请注意,我的语法与您的语法不同。

enter image description here

#!/bin/python3.7

from wand.image import Image
from wand.display import display

with Image(filename='lena.jpg') as img:
    img.frame(width=10, height=10)
    img.save(filename='lena_frame.jpg')
    display(img)


enter image description here

添加:

根据上述问题,它实际上在ImageMagick 7上失败。我已经向Python Wand开发人员报告了一个错误。