Le 29/11/12 11:41, Vincent Vande Vyvre a écrit : > I'm trying to see what option is supported by QImageWriter(). > > A test code: > ----------------------------------------------------------------------------------------------------- > # -*- coding: utf-8 -*- > > from PyQt4.QtGui import QImageWriter, QImageIOHandler > > frmts = ['bmp', 'bw', 'eps', 'ico', 'jp2', 'jpg', 'pcx', > 'pgm', 'png', 'ppm', 'rgb', 'rgba', 'sgi', 'tga', > 'tiff', 'xbm', 'xpm', 'xv'] > > opts = [QImageIOHandler.CompressionRatio, QImageIOHandler.Gamma, > QImageIOHandler.Quality] > > iw = QImageWriter() > for fr in frmts: > print fr, "\t", > iw.setFormat(fr) > for opt in opts: > print iw.supportsOption(opt), > print > > ------------------------------------------------------------------------------------------------------ > > But, for all formats the options are False: > > ... > jpg False False False > pcx False False False > pgm False False False > png False False False > ppm False False False > tga False False False > tiff False False False > ... > > Python 2.7 > PyQt4 4.9.1 > Python 3.3 > PyQt4 4.9.5 > > Thanks for all advices. > > Found it, the QImageWriter needs a file name before request for the support of option.
This works: ------------------------------------------------------------ for fr in frmts: print fr, "\t", iw.setFileName("imgfile." + fr) iw.setFormat(fr) for opt in opts: print iw.supportsOption(opt), print ------------------------------------------------------------ -- Vincent V.V. Oqapy <https://launchpad.net/oqapy> . Qarte <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager> _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt