I'm trying to load an image (a jpeg in that case from bytes, as it is downloaded from web content). I've already consulted some posts (for ex. 1 & 2), but for some reason I can't reproduce those answers, though JPEG is a wholy implemented format by PyQT4 as stated in the doc.
Let's say the picture to load in a QImage is this one.
I'm first downloading picture using request (though I'm certain this isn't related to this particular problem - I put it here mainly for portability reasons...).
import requests
r = requests.get(href, stream=True)
pict_bytes = r.content
After that, I can check this image is 100% correct using PIL and io modules :
from PIL import Image
import io
image = Image.open(io.BytesIO(pict_bytes))
image.show()
image.save('./test.jpeg')
It gets confusing afterwards, while trying to convert bytes to QImage :
from PyQt4 import QtGui
qim = QtGui.QImage()
qim.loadFromData(pict_bytes)
qim.loadFromData(..) returns False whatever the picture I chose, which I can't understand regarding to the function's description in the doc. I also checked directly from the file :
with open('./test.jpeg', 'rb') as f:
content = f.read()
qim.loadFromData(content)
Is there something obvious that I missed, or is this some strange comportment of PyQt4 with python 3 ? I would be grateful for your insights...
EDIT
I'm starting to believe there is some bug here (responses are all coherent with what I had already tried, in one way or another). Something doesn't feel quite right with the PyQt4 QImage (as well as QPixmap I suspect).
I'm currently using Windows 10 (and used Windows 2008 Server at the office), Winpython 3.6 x64, with PyQt4 4.11.4 installed from the unofficial depositery of Christoph Gohlke.