PythonQt.QtGui.QImageWriter · declarations 001
Back to PythonQt.QtGui.QImageWriter
ImageWriterError
instance-attribute
ImageWriterError: type
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
canWrite
canWrite() -> bool
X.canWrite() -> bool
Supplemental documentation: Qt 5 reference:
bool QImageWriter::canWrite() const
Returns true if QImageWriter
can write the image; i.e., the image format is supported and the assigned device is open
for reading.
See also write(), setDevice(), and setFormat().
Upstream PySide2 reference signatures (binding differences may apply):
canWrite(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#canWrite
compression
compression() -> int
X.compression() -> int
Supplemental documentation: Qt 5 reference:
int QImageWriter::compression() const
Returns the compression of the image.
See also setCompression().
Upstream PySide2 reference signatures (binding differences may apply):
compression(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#compression
device
device() -> Any
X.device() -> PythonQt.QtCore.QIODevice
Supplemental documentation: Qt 5 reference:
QIODevice *QImageWriter::device() const
Returns the device currently assigned to
QImageWriter, or nullptr if no
device has been assigned.
See also setDevice().
Upstream PySide2 reference signatures (binding differences may apply):
device(self) -> PySide2.QtCore.QIODevice
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#device
error
error() -> Any
X.error()
Supplemental documentation: Qt 5 reference:
QImageWriter::ImageWriterError QImageWriter::error() const
Returns the type of error that last occurred.
See also ImageWriterError and errorString().
Upstream PySide2 reference signatures (binding differences may apply):
error(self) -> PySide2.QtGui.QImageWriter.ImageWriterError
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#error
errorString
errorString() -> str
X.errorString() -> str
Supplemental documentation: Qt 5 reference:
QString QImageWriter::errorString() const
Returns a human readable description of the last error that occurred.
See also error().
Upstream PySide2 reference signatures (binding differences may apply):
errorString(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#errorString
fileName
fileName() -> str
X.fileName() -> str
Supplemental documentation: Qt 5 reference:
QString QImageWriter::fileName() const
If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file QImageWriter writes to. Otherwise (i.e., if no device has been assigned or the device is not a QFile), an empty QString is returned.
See also setFileName() and setDevice().
Upstream PySide2 reference signatures (binding differences may apply):
fileName(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#fileName
format
format() -> Any
X.format() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QImageWriter::format() const
Returns the format QImageWriter uses for writing images.
See also setFormat().
Upstream PySide2 reference signatures (binding differences may apply):
format(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#format
gamma
gamma() -> float
X.gamma() -> float
Upstream PySide2 reference signatures (binding differences may apply):
gamma(self) -> float
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#gamma
optimizedWrite
optimizedWrite() -> bool
X.optimizedWrite() -> bool
Supplemental documentation: Qt 5 reference:
bool QImageWriter::optimizedWrite() const
Returns whether optimization has been turned on for writing the image.
This function was introduced in Qt 5.5.
See also setOptimizedWrite().
Upstream PySide2 reference signatures (binding differences may apply):
optimizedWrite(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#optimizedWrite
progressiveScanWrite
progressiveScanWrite() -> bool
X.progressiveScanWrite() -> bool
Supplemental documentation: Qt 5 reference:
bool QImageWriter::progressiveScanWrite() const
Returns whether the image should be written as a progressive image.
This function was introduced in Qt 5.5.
See also setProgressiveScanWrite().
Upstream PySide2 reference signatures (binding differences may apply):
progressiveScanWrite(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#progressiveScanWrite
quality
quality() -> int
X.quality() -> int
Supplemental documentation: Qt 5 reference:
int QImageWriter::quality() const
Returns the quality setting of the image format.
See also setQuality().
Upstream PySide2 reference signatures (binding differences may apply):
quality(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#quality
setCompression
setCompression(compression: int) -> None
X.setCompression(compression)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setCompression(int compression)
This is an image format specific function that set the compression of an image. For image formats that do not support setting the compression, this value is ignored.
The value range of compression depends on the image format. For example, the "tiff" format supports two values, 0(no compression) and 1(LZW-compression).
See also compression().
Upstream PySide2 reference signatures (binding differences may apply):
setCompression(self, compression: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setCompression
setDevice
setDevice(device: Any) -> None
X.setDevice(device)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setDevice(QIODevice *device)
Sets QImageWriter's device to device. If a device has already been set, the old device is removed from QImageWriter and is otherwise left unchanged.
If the device is not already open, QImageWriter will attempt to open the device in QIODevice::WriteOnly mode by calling open(). Note that this does not work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where more logic is required to open the device.
See also device() and setFileName().
Upstream PySide2 reference signatures (binding differences may apply):
setDevice(self, device: PySide2.QtCore.QIODevice) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setDevice
setFileName
setFileName(fileName: str) -> None
X.setFileName(fileName)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setFileName(const QString \&fileName)
Sets the file name of QImageWriter to fileName. Internally, QImageWriter will create a QFile and open it in QIODevice::WriteOnly mode, and use this file when writing images.
See also fileName() and setDevice().
Upstream PySide2 reference signatures (binding differences may apply):
setFileName(self, fileName: str) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setFileName
setFormat
setFormat(format: Any) -> None
X.setFormat(format)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setFormat(const QByteArray \&format)
Sets the format QImageWriter will use when writing images, to format. format is a case insensitive text string. Example:
QImageWriter writer;
writer.setFormat("png"); // same as writer.setFormat("PNG");
You can call supportedImageFormats() for the full list of formats QImageWriter supports.
See also format().
Upstream PySide2 reference signatures (binding differences may apply):
setFormat(self, format: PySide2.QtCore.QByteArray) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setFormat
setGamma
setGamma(gamma: float) -> None
X.setGamma(gamma)
Upstream PySide2 reference signatures (binding differences may apply):
setGamma(self, gamma: float) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setGamma
setOptimizedWrite
setOptimizedWrite(optimize: bool) -> None
X.setOptimizedWrite(optimize)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setOptimizedWrite(bool optimize)
This is an image format-specific function which sets the optimize flags when writing images. For image formats that do not support setting an optimize flag, this value is ignored.
The default is false.
This function was introduced in Qt 5.5.
See also optimizedWrite().
Upstream PySide2 reference signatures (binding differences may apply):
setOptimizedWrite(self, optimize: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setOptimizedWrite
setProgressiveScanWrite
setProgressiveScanWrite(progressive: bool) -> None
X.setProgressiveScanWrite(progressive)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setProgressiveScanWrite(bool progressive)
This is an image format-specific function which turns on progressive scanning when writing images. For image formats that do not support setting a progressive scan flag, this value is ignored.
The default is false.
This function was introduced in Qt 5.5.
See also progressiveScanWrite().
Upstream PySide2 reference signatures (binding differences may apply):
setProgressiveScanWrite(self, progressive: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setProgressiveScanWrite
setQuality
setQuality(quality: int) -> None
X.setQuality(quality)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setQuality(int quality)
Sets the quality setting of the image format to quality.
Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) encoding execution time and compression level. This function sets the level of that tradeoff for image formats that support it. For other formats, this value is ignored.
The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low visual quality, high compression) to 100 (high visual quality, low compression).
See also quality().
Upstream PySide2 reference signatures (binding differences may apply):
setQuality(self, quality: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setQuality
setSubType
setSubType(type: Any) -> None
X.setSubType(type)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setSubType(const QByteArray \&type)
This is an image format specific function that sets the subtype of the image to type. Subtype can be used by a handler to determine which format it should use while saving the image.
For example, saving an image in DDS format with A8R8G8R8 subtype:
QImageWriter writer("some/image.dds");
if (writer.supportsOption(QImageIOHandler::SubType))
writer.setSubType("A8R8G8B8");
writer.write(image);
This function was introduced in Qt 5.4.
See also subType().
Upstream PySide2 reference signatures (binding differences may apply):
setSubType(self, type: PySide2.QtCore.QByteArray) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setSubType
setText
setText(key: str, text: str) -> None
X.setText(key, text)
Supplemental documentation: Qt 5 reference:
void QImageWriter::setText(const QString \&key, const QString \&text)
Sets the image text associated with the key key to text. This is useful for storing copyright information or other information about the image. Example:
QImage image("some/image.jpeg");
QImageWriter writer("images/outimage.png", "png");
writer.setText("Author", "John Smith");
writer.write(image);
If you want to store a single block of data (e.g., a comment), you can pass an empty key, or use a generic key like "Description".
The key and text will be embedded into the image data after calling write().
Support for this option is implemented through QImageIOHandler::Description.
This function was introduced in Qt 4.1.
See also QImage::setText() and QImageReader::text().
Upstream PySide2 reference signatures (binding differences may apply):
setText(self, key: str, text: str) -> None
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#setText
subType
subType() -> Any
X.subType() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QImageWriter::subType() const
Returns the subtype of the image.
This function was introduced in Qt 5.4.
See also setSubType().
Upstream PySide2 reference signatures (binding differences may apply):
subType(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#subType
supportedImageFormats
supportedImageFormats() -> Any
X.supportedImageFormats()
Supplemental documentation: Qt 5 reference:
[static] QList\<QByteArray> QImageWriter::supportedImageFormats()
Returns the list of image formats supported by QImageWriter.
By default, Qt can write the following formats:
| Format | MIME type | Description |
|---|---|---|
| BMP | image/bmp | Windows Bitmap |
| JPG | image/jpeg | Joint Photographic Experts Group |
| PNG | image/png | Portable Network Graphics |
| PBM | image/x-portable-bitmap | Portable Bitmap |
| PGM | image/x-portable-graymap | Portable Graymap |
| PPM | image/x-portable-pixmap | Portable Pixmap |
| XBM | image/x-xbitmap | X11 Bitmap |
| XPM | image/x-xpixmap | X11 Pixmap |
Reading and writing SVG files is supported through the Qt SVG module. The Qt Image Formats module provides support for additional image formats.
Note that the QApplication instance must be created before this function is called.
See also setFormat(), QImageReader::supportedImageFormats(), and QImageIOPlugin.
Upstream PySide2 reference signatures (binding differences may apply):
supportedImageFormats() -> typing.List[PySide2.QtCore.QByteArray]
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#supportedImageFormats
supportedMimeTypes
supportedMimeTypes() -> Any
X.supportedMimeTypes()
Supplemental documentation: Qt 5 reference:
[static] QList\<QByteArray> QImageWriter::supportedMimeTypes()
Returns the list of MIME types supported by QImageWriter.
Note that the QApplication instance must be created before this function is called.
See also supportedImageFormats() and QImageReader::supportedMimeTypes().
Upstream PySide2 reference signatures (binding differences may apply):
supportedMimeTypes() -> typing.List[PySide2.QtCore.QByteArray]
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#supportedMimeTypes
supportedSubTypes
supportedSubTypes() -> Any
X.supportedSubTypes()
Supplemental documentation: Qt 5 reference:
QList\<QByteArray> QImageWriter::supportedSubTypes() const
Returns the list of subtypes supported by an image.
This function was introduced in Qt 5.4.
Upstream PySide2 reference signatures (binding differences may apply):
supportedSubTypes(self) -> typing.List[PySide2.QtCore.QByteArray]
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#supportedSubTypes
supportsOption
supportsOption(option: Any) -> bool
X.supportsOption(option) -> bool
Supplemental documentation: Qt 5 reference:
bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const
Returns true if the writer supports option; otherwise returns false.
Different image formats support different options. Call this function to determine whether a certain option is supported by the current format. For example, the PNG format allows you to embed text into the image's metadata (see text()).
QImageWriter writer(fileName);
if (writer.supportsOption(QImageIOHandler::Description))
writer.setText("Author", "John Smith");
Options can be tested after the writer has been associated with a format.
This function was introduced in Qt 4.2.
See also QImageReader::supportsOption() and setFormat().
Upstream PySide2 reference signatures (binding differences may apply):
supportsOption(self, option: PySide2.QtGui.QImageIOHandler.ImageOption) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#supportsOption
write
write(image: Any) -> bool
X.write(image) -> bool
Supplemental documentation: Qt 5 reference:
bool QImageWriter::write(const QImage \&image)
Writes the image image to the assigned device or file name. Returns true on success;
otherwise returns false. If the operation fails, you can call
error() to find the type
of error that occurred, or
errorString() to get
a human readable description of the error.
See also canWrite(), error(), and errorString().
Upstream PySide2 reference signatures (binding differences may apply):
write(self, image: PySide2.QtGui.QImage) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qimagewriter.html#write