weird matplotlib imread question for png

I am using anaconda(Python 2.7.6 |Anaconda 1.9.2 (32-bit)| (default,
Nov 11 2013, 10:50:31) [MSC v.1500 32 bit (Intel)] on win32) on
windows 7 64 bits
And the matplotlib is 1.4.3, numpy is 1.9.2, and scipy is 0.15.1,
which are all been updated by 'conda update xx'

As http://matplotlib.org/api/pyplot_api.html says
[quote]
matplotlib.pyplot.imread(*args, **kwargs) Read an image from a file
into an array.

Return value is a numpy.array. For grayscale images, the return array
is MxN. For RGB images, the return value is MxNx3. For RGBA images the
return value is MxNx4.
[/quote]

But if I read a 128*128*8 BPP gray PNG file, the array.shape is (128,
128, 3); if I read a 128*128*24BPP color PNG file, the array.shape is
(128, 128, 4)

Why? Thanks

[code]
from pylab import *

imgGrayPng=imread('python-gray.png')
print (imgGrayPng.shape) #(128, 128, 3)

imgGrayJpg=imread('python-gray.jpg')
print (imgGrayJpg.shape) #(128, 128)

imgColorPng=imread('python-color.png')
print (imgColorPng.shape) #(128, 128, 4)

imgColorJpg=imread('python-color.jpg')
print (imgColorJpg.shape) #(128, 128, 3)

[/code]

Are you sure your png "24bpp" does not have a transparency channel?

···

Le mardi 14 avril 2015 à 18:15 +0800, oyster a écrit :

I am using anaconda(Python 2.7.6 |Anaconda 1.9.2 (32-bit)| (default,
Nov 11 2013, 10:50:31) [MSC v.1500 32 bit (Intel)] on win32) on
windows 7 64 bits
And the matplotlib is 1.4.3, numpy is 1.9.2, and scipy is 0.15.1,
which are all been updated by 'conda update xx'

As http://matplotlib.org/api/pyplot_api.html says
[quote]
matplotlib.pyplot.imread(*args, **kwargs) Read an image from a file
into an array.

Return value is a numpy.array. For grayscale images, the return array
is MxN. For RGB images, the return value is MxNx3. For RGBA images the
return value is MxNx4.
[/quote]

But if I read a 128*128*8 BPP gray PNG file, the array.shape is (128,
128, 3); if I read a 128*128*24BPP color PNG file, the array.shape is
(128, 128, 4)

--
Fabrice