Actually, digging around the internet I found this. It looks a bit convoluted but it seems to work - at least for my limited needs. Is there anything neater?
Code:
data = container.raw_data(imgname)
pixmap = QPixmap()
pixmap.loadFromData(data)
... do some pixmap changes via GUI ...
pixmap.save(container.name_to_abspath(imgname))
fmt = imgname.rpartition('.')[-1].upper()
byte_array = QByteArray()
buffer = QBuffer(byte_array)
buffer.open(QIODevice.WriteOnly)
if pixmap.save(buffer, fmt):
with container.open(imgname, 'wb') as f:
f.write(buffer.data())