How to show PIL Image in ipython notebook

前端 未结 12 1376
抹茶落季
抹茶落季 2020-12-22 23:18

This is my code

from PIL import Image
pil_im = Image.open(\'data/empire.jpg\')

I would like to do some image manipulation on it, and then s

12条回答
  •  天涯浪人
    2020-12-22 23:50

    case python3

    from PIL import Image
    from IPython.display import HTML
    from io import BytesIO
    from base64 import b64encode
    
    pil_im = Image.open('data/empire.jpg')
    b = BytesIO()  
    pil_im.save(b, format='png')
    HTML("".format(b64encode(b.getvalue()).decode('utf-8')))
    

提交回复
热议问题