Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: default/common way to read png images

Tags:

python

image

png

I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux distributions.)

If there is none, what is the most common lib?

Many search results hint me to Python Imaging Library. If this is some well known Python-lib for reading images, why isn't it included in Python?

like image 394
Albert Avatar asked Feb 04 '10 15:02

Albert


People also ask

How do I read a PNG file?

How to open a PNG file. Nearly all built-in image editing programs can open PNG files. Whether you use a Mac or Windows computer, simply search for the file name and double-click on it. You can then choose the program you want to use from the list of options your computer gives you.

Can cv2 Imread read PNG?

The syntax of imread() function contains a second argument whose default value is cv2. IMREAD_COLOR. Any transparency present in the image is not read. To read PNG images with transparency (alpha) channel, use cv2.

How do you access an image in Python?

We use cv2. imread() function to read an image. The image should be placed in the current working directory or else we need to provide the absoluate path.


2 Answers

No, there are no modules in the standard library for reading/writing/processing images directly. But the most common library might be PIL (Python Imaging Library). Many projects are not included in the standard library because they are 1) totally optional and 2) cannot be maintained by the few Python core developers.

like image 197
AndiDog Avatar answered Nov 03 '22 08:11

AndiDog


Coming late to the party, I would strongly suggest one of the Python interfaces to the ImageMagick library (Wand worked well in my testing, I'll know more soon...)

ImageMagick is a more powerful library and also pretty well a de-facto standard across many languages. Appealing to a wider base, they also have a wider developer base as a result.

like image 23
Tom Swirly Avatar answered Nov 03 '22 09:11

Tom Swirly