Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image to numpy-array: JPG vs. PNG

My system: Mac OS X 10.7
Python 2.7.1
NumPy version 1.5.1

My code:

image = openImage(fileDir)  
print image  
image = np.asarray(image)  
print image

If I run this:

python main.py 1010.png

the output is:

<PIL.PngImagePlugin.PngImageFile image mode=RGB size=10x10 at 0x10A835368>  
[[[226 226 226] ...    `

If I run this:

python main.py google.jpg 

the output is:

<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=488x640 at 0x10140B368>  
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=488x640 at 0x10140B368>

I cannot figure out why numpy can converts png's but can't do it on jpg's, why? How can I solve this?

edit:

ok tried with

image.show()

and got following error-message:

IOError: decoder jpeg not available

i solved the problem with the information i got from this page:
http://mariz.org/blog/2007/01/26/mac-os-x-decoder-jpeg-not-available/

like image 302
tienbuiDE Avatar asked Jan 20 '12 22:01

tienbuiDE


1 Answers

i solved the problem with the information i got from this page:

http://mariz.org/blog/2007/01/26/mac-os-x-decoder-jpeg-not-available/

like image 165
tienbuiDE Avatar answered Nov 09 '22 01:11

tienbuiDE