简体   繁体   English

wand.Image 对象到 PIL Image

[英]wand.Image object to PIL Image

I currently have an image in the wand.image format.我目前有一张 wand.image 格式的图像。 I need to convert it to PIL format so that I can continue working with it.我需要将其转换为 PIL 格式,以便我可以继续使用它。 It is and RGB image.它是 RGB 图像。 I cant seem to find anywhere how to do it.我似乎无法在任何地方找到如何做到这一点。 I have tried to convert it to an np array and then read the np array into the PIL image.我试图将其转换为 np 数组,然后将 np 数组读入 PIL 图像。 Thank you for any help.感谢您的任何帮助。 Here is my code if it helps:如果有帮助,这是我的代码:

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