PyQt4 - Watermark Image

I am trying to open a PNG image and write text (watermark) via QImage and QPainter. The code works 100% on Linux, but when I run it on Windows XP (not tested with any other version of Windows), the text is never written to the image. I have code in try / except block but no errors are returned.

image = QtGui.QImage('demo.png')

painter = QtGui.QPainter()
painter.begin(image)
painter.setOpacity(0.8)
painter.setPen(QtCore.Qt.blue)
painter.setFont(QtGui.QFont('arial', 12))
painter.drawText(image.rect(), QtCore.Qt.AlignCenter, 'Watermark')
painter.end()

image.save('demo.png')

      

Using Python 2.6.2, PyQt 4.5.4

Any ideas?

+2


source to share


2 answers


The first thing that comes to my mind might not be looking for the specified font in Windows.



0


source


I am guessing that whatever png lib you are using on windows does not do transparency (correct)



0


source







All Articles