What is the difference between images in 'P' and 'L' mode in PIL?

前端 未结 3 1902
太阳男子
太阳男子 2020-11-22 15:35

According to https://pillow.readthedocs.io/en/3.1.x/handbook/concepts.html#concept-modes,

  1. What are the difference between them?
  2. Can we convert from on
3条回答
  •  盖世英雄少女心
    2020-11-22 15:52

    "L" mode maps to black and white pixels (and in between). "P" mode maps with a color palette. You can convert image to one of these modes.

    from PIL import Image
    
    im = Image.open("im.jpg")
    im_l = im.convert('L')
    im_p = im.convert('P')
    
    im.show()
    im_l.show()
    im_p.show()
    

提交回复
热议问题