Alex Rivera | Logout

How can I get the depth of a jpg file?

Asked 2010-01-03T22:24:09.003
11

I want to retrieve the bit depth for a jpeg file using Python.

Using the Python Imaging Library:

import Image
data = Image.open('file.jpg')
print data.depth

However, this gives me a depth of 8 for an obviously 24-bit image. Am I doing something wrong? Is there some way to do it with pure Python code?

Thanks in advance.

Edit: It's data.bits not data.depth.

Edit
Report

1 Answer

7

Jpeg files don't have bit depth in the same manner as GIF or PNG files. The transform used to create the Jpeg data renders a continuous color spectrum on decompression.

answered 2010-01-03T22:31:22.233

Your Answer