簡體   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