Skip to content
Advertisement

Using pythons open function for .png Image

Im getting an error when using pythons inbuild function “open” and don’t know how to get it to work for png files.

Examplecode: img =open('here.png').read()

Error: UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 101: character maps to <undefined>

Advertisement

Answer

To open images, i suggest you to use opencv or PIL module of python.
Using OpenCV:

JavaScript

Using PIL:

JavaScript

If you just want to open using open :

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement