[PyKDE] How to display GIF and JPEG
gvermeul at labs.polycnrs-gre.fr
Thu Mar 29 09:23:03 BST 2001
Here is an example, which fills the background of
a future killer app with .gif or .jpg picture.
from qt import *
import Image # the PythonWare Imaging Library
def __init__(self, filename, *args):
apply(QWidget.__init__, (self,) + args)
self.pixmap = QPixmap()
#if not self.pixmap.load(filename): # Qt2/Linux loads *.gif and *.jpg!
print 'Could not load "%s", converting to "%s.png"' % \
image = Image.open(filename)
image.save(filename + '.png') # saved format depends on extension
self.pixmap.load(filename + '.png')
app = QApplication(sys.argv)
# lena.gif and lena.jpg are included in the PythonWare Imaging Library
demo = Viewer("lena.jpg") # or demo = Viewer("lena.gif")
However, on Mandrake-Linux-7.2 and Qt-2.2.1 it works without
the PythonWare Image Library. Therefore I had to replace the
if not self ....
Sheng-Te Tsao wrote:
> Thanks for the info, but I only found support for tk and windows in that
> library. Is there any code that shows how
> to use PIL with QT's QImageIO extension?
> At 09:42 AM 3/28/2001 +0200, Gerard Vermeulen wrote:
> >Sheng-Te Tsao wrote:
> > >I am wondering if someone can show me some code that demonstrates how to
> > >read GIF or JPEG files using PyQT because unlike PNG, they are not compiled
> > >into the qt221.dll supplied with PyQT for Windows. Note that I do have
> > >access to the QT source code for Windows yet, although I do plan to buy a
> > >license in the near future, once I convince my company that PyQT is the way
> > >to go.
> >Take a look at the PythonWare Image library
> >It should allow you to convert the GIF/JPEG files in memory to a format
> >that can be displayed by Qt.
More information about the PyQt