简体   繁体   中英

wand.Image object to PIL Image

I currently have an image in the wand.image format. I need to convert it to PIL format so that I can continue working with it. It is and RGB image. 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. 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') 由于某种原因修复了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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