You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error in imdecode, acts differently than imread and doesn't things like orientation and more correctly #8172
There appears to be a bug in python cv2.imdecode behaves differently than cv2.imread, imread will correctly detect orientation and load the image properly, meanwhile imdecode will neither detect orientation or load the image properly. I cannot upload the input image itself as it contains sensitive data, but it's a completely standard image from an iPhone 6 with the following meta data (from file), displaying orientation etc:
fh = open('somefile.jpg', 'r') # or some other way of providing in memory streams, i.e. posted from a webserver
arr = np.asarray(bytearray(fh.read()), dtype=np.uint8)
tmp = cv2.imdecode(arr, -1) # 'load it as it is' or 1 for 3channel
cv2.imwrite('/tmp/loadedfile.jpg', tmp)
This will write the image back incorrectly to the disk, meanwhile if i either write the memory stream to disk and then use imread, it handles orientation and so forth correctly.
Activity
mshabunin commentedon Feb 20, 2017
The EXIF orientation support has been implemented for
imreadonly.brian-armstrong-discord commentedon Mar 29, 2017
Having
imdecodedo this would be really usefulNinnOgTonic commentedon Mar 29, 2017
indeed, having to write the file from memory to disk, to then create a fh to get the correct effect is an insane work around for this.