[PyQt] Usage of QImageWriter.supportsOption()
Phil Thompson
phil at riverbankcomputing.com
Thu Nov 29 12:23:48 GMT 2012
On Thu, 29 Nov 2012 11:41:52 +0100, Vincent Vande Vyvre
<vincent.vandevyvre at swing.be> wrote:
> 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.
QImageWriter can only handle one format, so create a new one in the loop.
Phil
More information about the PyQt
mailing list