繁体   English   中英

wand.Image 对象到 PIL Image

[英]wand.Image object to PIL Image

我目前有一张 wand.image 格式的图像。 我需要将其转换为 PIL 格式,以便我可以继续使用它。 它是 RGB 图像。 我似乎无法在任何地方找到如何做到这一点。 我试图将其转换为 np 数组,然后将 np 数组读入 PIL 图像。 感谢您的任何帮助。 如果有帮助,这是我的代码:

from PIL import Image, ImageFilter
from wand.image import Image as Image2

with Image2(filename=join(img_path,file)) as img:
   img.virtual_pixel = 'transparent'
   test_image = Image.fromarray(np.array(img), 'RGB')

data_image = Image.open(io.BytesIO(img.make_blob("png"))).convert('RGB') 由于某种原因修复了这个问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM