How do I read an image file using Python?


Question

How do I read an image file and decode it using Python?

1
56
9/20/2010 12:27:24 PM

The word "read" is vague, but here is an example which reads a jpeg file using the Image class, and prints information about it.

from PIL import Image
jpgfile = Image.open("picture.jpg")

print(jpgfile.bits, jpgfile.size, jpgfile.format)
48
6/14/2018 2:59:57 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon