I have a table in my DB which contains information about images (like width, height, content-type, file-type and file content). In column file_content
stored entire image (not pixel data or something else - entire file readed and stored as binary data). Now I want to create QImage (or QPixmap) from this record in my application on Python+PySide. How can I do it?
I tried loadFromData, but it is expects raw pixel data, not file with header like in my case.
Actually, I have no idea hot to solve it.
UPD: My code sample which does not works:
with open('Koala.jpg', 'r') as f:
content = f.read()
self.image = QtGui.QImage()
print self.image.loadFromData(content)
Result:
False
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
JPEG datastream contains no image