Added bit_depth attribute to PngImageFile#9601
Added bit_depth attribute to PngImageFile#9601ajslater wants to merge 3 commits intopython-pillow:mainfrom
Conversation
Could you elaborate on this? Pillow attempts to deal with this kind of low level information so you don't have to. You should be able to infer a less-precise bit depth from The following code would let you determine a numeric value for the bit depth at the moment. from PIL import Image, PngImagePlugin
with Image.open("Tests/images/hopper.png") as im:
for bitDepth_colorType, mode_rawmode in PngImagePlugin._MODES.items():
if im.png.im_rawmode == mode_rawmode[1]:
print("Bit depth:", bitDepth_colorType[0])I acknowledge my suggestion is inelegant and uses a private property. If we did go with your suggestion, I think it would be better as another key in
I find this comment confusing. What do you think is undone about this PR? Or are you just saying that you're willing to accept feedback? |
I find it useful when working with PNGs to know their bit depth and since i use Pillow to detect image formats as well as manipulate images I thought it might be a useful addition.
This just reads a well known byte from the png stream and stores it on the PngImageFile.
Tell me if this looks useful and I can modify this PR to work well as a Pillow contribution.