Reputation: 174
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>
Upvotes: 2
Views: 8106
Reputation: 1
I'm using imageio for python3 that calls the pillow package which is a branch of PIL.
frame = imageio.imread('png here')
and to make sure the frame is not being converted to something else like uint16 => uint8, I make sure of the dtype
print (frame.dtype)
Upvotes: 0
Reputation: 496
If you are trying to send the image file through FTP you might need to open the file use this
file = open(file_location,'rb')
and then you can use this to send the file
ftp.storbinary('STOR '+file_location, file)
I use it a million times daily :)
Upvotes: 2
Reputation: 4992
To open images, i suggest you to use opencv
or PIL
module of python.
Using OpenCV:
import cv2
img = cv2.imread('here.png',0)
Using PIL:
from PIL import Image
im = Image.open("here.png")
im.show()
If you just want to open using open
:
img =open('here.png','rb').read()
Upvotes: 3