I have this PySide2 code which works on Linux with Python 2.7
from PySide2.QtCore import QBuffer, QByteArray
...
image = self.clipboard.image()
ba = QByteArray()
buffer = QBuffer(ba)
buffer.open(QIODevice.WriteOnly)
image.save(buffer, "PNG")
return bytes(buffer.data())
But on windows with Python 3.6 it fails here:
File "C:\....foo.py", line 93, in image_to_png
return bytes(buffer.data())
Exception:
TypeError: 'bytes' object cannot be interpreted as an integer
What is the most simple way to get the PNG as bytes?
I would like to avoid to create a temporary file, since it is not needed for this context.
(I use PySide2, but I could switch to a different python-QT binding if you think it makes more sense. Please leave a comment if you think so)
buffer.data()?