Search code examples
image-processingpython-imaging-librarygoogle-colaboratory

can't show an image using PIL on google colab


I am trying to use PIL to show an image. I know that I can use other modules to do that. I am working on google colab. But I can't figure out why PIL is not showing output image.

% matplotlib inline
import numpy as np
import PIL
im=Image.open('/content/drive/My Drive/images-process.jpeg')
print(im.width, im.height, im.mode, im.format, type(im))
im.show()

output: 739 415 RGB JPEG < class 'PIL.JpegImagePlugin.JpegImageFile'>


Solution

  • Instead of

    im.show()
    

    Try just

    im
    

    Colab should try to display it on its own. See example notebook