Search code examples
pythonpython-imaging-librarywand

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')

Solution

  • data_image = Image.open(io.BytesIO(img.make_blob("png"))).convert('RGB') fixes the issue for some reason