Skip to content

PythonQt.QtGui.QImageReader · declarations 001

Back to PythonQt.QtGui.QImageReader

DeviceError instance-attribute

DeviceError: Any

FileNotFoundError instance-attribute

FileNotFoundError: Any

ImageReaderError instance-attribute

ImageReaderError: 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

InvalidDataError instance-attribute

InvalidDataError: Any

UnsupportedFormatError instance-attribute

UnsupportedFormatError: Any

autoDetectImageFormat

autoDetectImageFormat() -> bool

X.autoDetectImageFormat() -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::autoDetectImageFormat() const

Returns true if image format autodetection is enabled on this image reader; otherwise returns false. By default, autodetection is enabled.

See also setAutoDetectImageFormat().

Upstream PySide2 reference signatures (binding differences may apply):

autoDetectImageFormat(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#autoDetectImageFormat

autoTransform

autoTransform() -> bool

X.autoTransform() -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::autoTransform() const

Returns true if the image handler will apply transformation metadata on read().

This function was introduced in Qt 5.5.

See also setAutoTransform(), transformation(), and read().

Upstream PySide2 reference signatures (binding differences may apply):

autoTransform(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#autoTransform

backgroundColor

backgroundColor() -> Any

X.backgroundColor() -> PythonQt.QtGui.QColor

Supplemental documentation: Qt 5 reference:

QColor QImageReader::backgroundColor() const

Returns the background color that's used when reading an image. If the image format does not support setting the background color an invalid color is returned.

This function was introduced in Qt 4.1.

See also setBackgroundColor() and read().

Upstream PySide2 reference signatures (binding differences may apply):

backgroundColor(self) -> PySide2.QtGui.QColor

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#backgroundColor

canRead

canRead() -> bool

X.canRead() -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::canRead() const

Returns true if an image can be read for the device (i.e., the image format is supported, and the device seems to contain valid data); otherwise returns false.

canRead() is a lightweight function that only does a quick test to see if the image data is valid. read() may still return false after canRead() returns true, if the image data is corrupt.

Note: A QMimeDatabase lookup is normally a better approach than this function for identifying potentially non-image files or data.

For images that support animation, canRead() returns false when all frames have been read.

See also read(), supportedImageFormats(), and QMimeDatabase.

Upstream PySide2 reference signatures (binding differences may apply):

canRead(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#canRead

clipRect

clipRect() -> Any

X.clipRect() -> PythonQt.QtCore.QRect

Supplemental documentation: Qt 5 reference:

QRect QImageReader::clipRect() const

Returns the clip rect (also known as the ROI, or Region Of Interest) of the image. If no clip rect has been set, an invalid QRect is returned.

See also setClipRect().

Upstream PySide2 reference signatures (binding differences may apply):

clipRect(self) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#clipRect

currentImageNumber

currentImageNumber() -> int

X.currentImageNumber() -> int

Supplemental documentation: Qt 5 reference:

int QImageReader::currentImageNumber() const

For image formats that support animation, this function returns the sequence number of the current frame. If the image format doesn't support animation, 0 is returned.

This function returns -1 if an error occurred.

See also supportsAnimation(), QImageIOHandler::currentImageNumber(), and canRead().

Upstream PySide2 reference signatures (binding differences may apply):

currentImageNumber(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#currentImageNumber

currentImageRect

currentImageRect() -> Any

X.currentImageRect() -> PythonQt.QtCore.QRect

Supplemental documentation: Qt 5 reference:

QRect QImageReader::currentImageRect() const

For image formats that support animation, this function returns the rect for the current frame. Otherwise, a null rect is returned.

See also supportsAnimation() and QImageIOHandler::currentImageRect().

Upstream PySide2 reference signatures (binding differences may apply):

currentImageRect(self) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#currentImageRect

decideFormatFromContent

decideFormatFromContent() -> bool

X.decideFormatFromContent() -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::decideFormatFromContent() const

Returns whether the image reader should decide which plugin to use only based on the contents of the datastream rather than on the file extension.

See also setDecideFormatFromContent().

Upstream PySide2 reference signatures (binding differences may apply):

decideFormatFromContent(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#decideFormatFromContent

device

device() -> Any

X.device() -> PythonQt.QtCore.QIODevice

Supplemental documentation: Qt 5 reference:

QIODevice *QImageReader::device() const

Returns the device currently assigned to QImageReader, 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/qimagereader.html#device

error

error() -> Any

X.error()

Supplemental documentation: Qt 5 reference:

QImageReader::ImageReaderError QImageReader::error() const

Returns the type of error that occurred last.

See also ImageReaderError and errorString().

Upstream PySide2 reference signatures (binding differences may apply):

error(self) -> PySide2.QtGui.QImageReader.ImageReaderError

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#error

errorString

errorString() -> str

X.errorString() -> str

Supplemental documentation: Qt 5 reference:

QString QImageReader::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/qimagereader.html#errorString

fileName

fileName() -> str

X.fileName() -> str

Supplemental documentation: Qt 5 reference:

QString QImageReader::fileName() const

If the currently assigned device is a QFile, or if setFileName() has been called, this function returns the name of the file QImageReader reads from. 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/qimagereader.html#fileName

format

format() -> Any

X.format() -> PythonQt.QtCore.QByteArray

Supplemental documentation: Qt 5 reference:

QByteArray QImageReader::format() const

Returns the format QImageReader uses for reading images.

You can call this function after assigning a device to the reader to determine the format of the device. For example:

QImageReader reader("image.png");
// reader.format() == "png"

If the reader cannot read any image from the device (e.g., there is no image there, or the image has already been read), or if the format is unsupported, this function returns an empty QByteArray().

See also setFormat() and supportedImageFormats().

Upstream PySide2 reference signatures (binding differences may apply):

format(self) -> PySide2.QtCore.QByteArray

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.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/qimagereader.html#gamma

imageCount

imageCount() -> int

X.imageCount() -> int

Supplemental documentation: Qt 5 reference:

int QImageReader::imageCount() const

For image formats that support animation, this function returns the total number of images in the animation. If the format does not support animation, 0 is returned.

This function returns -1 if an error occurred.

See also supportsAnimation(), QImageIOHandler::imageCount(), and canRead().

Upstream PySide2 reference signatures (binding differences may apply):

imageCount(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#imageCount

imageFormat

imageFormat() -> Any

X.imageFormat()

Supplemental documentation: Qt 5 reference:

QImage::Format QImageReader::imageFormat() const

Returns the format of the image, without actually reading the image contents. The format describes the image format QImageReader::read() returns, not the format of the actual image.

If the image format does not support this feature, this function returns an invalid format.

This function was introduced in Qt 4.5.

See also QImageIOHandler::ImageOption, QImageIOHandler::option(), and QImageIOHandler::supportsOption().

[static] QByteArray QImageReader::imageFormat(const QString \&fileName)

If supported, this function returns the image format of the file fileName. Otherwise, an empty string is returned.

[static] QByteArray QImageReader::imageFormat(QIODevice *device)

If supported, this function returns the image format of the device device. Otherwise, an empty string is returned.

See also QImageReader::autoDetectImageFormat().

Upstream PySide2 reference signatures (binding differences may apply):

imageFormat(device: PySide2.QtCore.QIODevice) -> PySide2.QtCore.QByteArray
imageFormat(fileName: str) -> PySide2.QtCore.QByteArray
imageFormat(self) -> PySide2.QtGui.QImage.Format

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#imageFormat

jumpToImage

jumpToImage(imageNumber: int) -> bool

X.jumpToImage(imageNumber) -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::jumpToImage(int imageNumber)

For image formats that support animation, this function skips to the image whose sequence number is imageNumber, returning true if successful or false if the corresponding image cannot be found.

The next call to read() will attempt to read this image.

See also jumpToNextImage() and QImageIOHandler::jumpToImage().

Upstream PySide2 reference signatures (binding differences may apply):

jumpToImage(self, imageNumber: int) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#jumpToImage

jumpToNextImage

jumpToNextImage() -> bool

X.jumpToNextImage() -> bool

Supplemental documentation: Qt 5 reference:

bool QImageReader::jumpToNextImage()

For image formats that support animation, this function steps over the current image, returning true if successful or false if there is no following image in the animation.

The default implementation calls read(), then discards the resulting image, but the image handler may have a more efficient way of implementing this operation.

See also jumpToImage() and QImageIOHandler::jumpToNextImage().

Upstream PySide2 reference signatures (binding differences may apply):

jumpToNextImage(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#jumpToNextImage

loopCount

loopCount() -> int

X.loopCount() -> int

Supplemental documentation: Qt 5 reference:

int QImageReader::loopCount() const

For image formats that support animation, this function returns the number of times the animation should loop. If this function returns -1, it can either mean the animation should loop forever, or that an error occurred. If an error occurred, canRead() will return false.

See also supportsAnimation(), QImageIOHandler::loopCount(), and canRead().

Upstream PySide2 reference signatures (binding differences may apply):

loopCount(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#loopCount

nextImageDelay

nextImageDelay() -> int

X.nextImageDelay() -> int

Supplemental documentation: Qt 5 reference:

int QImageReader::nextImageDelay() const

For image formats that support animation, this function returns the number of milliseconds to wait until displaying the next frame in the animation. If the image format doesn't support animation, 0 is returned.

This function returns -1 if an error occurred.

See also supportsAnimation(), QImageIOHandler::nextImageDelay(), and canRead().

Upstream PySide2 reference signatures (binding differences may apply):

nextImageDelay(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#nextImageDelay

quality

quality() -> int

X.quality() -> int

Supplemental documentation: Qt 5 reference:

int QImageReader::quality() const

Returns the quality setting of the image format.

This function was introduced in Qt 4.2.

See also setQuality().

Upstream PySide2 reference signatures (binding differences may apply):

quality(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#quality

read

read() -> Any

X.read() -> PythonQt.QtGui.QImage

Supplemental documentation: Qt 5 reference:

QImage QImageReader::read()

Reads an image from the device. On success, the image that was read is returned; otherwise, a null QImage is returned. You can then call error() to find the type of error that occurred, or errorString() to get a human readable description of the error.

For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.

See also canRead(), supportedImageFormats(), supportsAnimation(), and QMovie.

bool QImageReader::read(QImage *image)

This is an overloaded function.

Reads an image from the device into image, which must point to a QImage. Returns true on success; otherwise, returns false.

If image has same format and size as the image data that is about to be read, this function may not need to allocate a new image before reading. Because of this, it can be faster than the other read() overload, which always constructs a new image; especially when reading several images with the same format and size.

QImage icon(64, 64, QImage::Format_RGB32);
QImageReader reader("icon_64x64.bmp");
if (reader.read(&icon)) {
    // Display icon
}

For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.

See also canRead(), supportedImageFormats(), supportsAnimation(), and QMovie.

Upstream PySide2 reference signatures (binding differences may apply):

read(self) -> PySide2.QtGui.QImage

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#read

scaledClipRect

scaledClipRect() -> Any

X.scaledClipRect() -> PythonQt.QtCore.QRect

Supplemental documentation: Qt 5 reference:

QRect QImageReader::scaledClipRect() const

Returns the scaled clip rect of the image.

See also setScaledClipRect().

Upstream PySide2 reference signatures (binding differences may apply):

scaledClipRect(self) -> PySide2.QtCore.QRect

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#scaledClipRect

scaledSize

scaledSize() -> Any

X.scaledSize() -> PythonQt.QtCore.QSize

Supplemental documentation: Qt 5 reference:

QSize QImageReader::scaledSize() const

Returns the scaled size of the image.

See also setScaledSize().

Upstream PySide2 reference signatures (binding differences may apply):

scaledSize(self) -> PySide2.QtCore.QSize

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#scaledSize

setAutoDetectImageFormat

setAutoDetectImageFormat(enabled: bool) -> None

X.setAutoDetectImageFormat(enabled)

Supplemental documentation: Qt 5 reference:

void QImageReader::setAutoDetectImageFormat(bool enabled)

If enabled is true, image format autodetection is enabled; otherwise, it is disabled. By default, autodetection is enabled.

QImageReader uses an extensive approach to detecting the image format; firstly, if you pass a file name to QImageReader, it will attempt to detect the file extension if the given file name does not point to an existing file, by appending supported default extensions to the given file name, one at a time. It then uses the following approach to detect the image format:

  • Image plugins are queried first, based on either the optional format string, or the file name suffix (if the source device is a file). No content detection is done at this stage. QImageReader will choose the first plugin that supports reading for this format.
  • If no plugin supports the image format, Qt's built-in handlers are checked based on either the optional format string, or the file name suffix.
  • If no capable plugins or built-in handlers are found, each plugin is tested by inspecting the content of the data stream.
  • If no plugins could detect the image format based on data contents, each built-in image handler is tested by inspecting the contents.
  • Finally, if all above approaches fail, QImageReader will report failure when trying to read the image.

By disabling image format autodetection, QImageReader will only query the plugins and built-in handlers based on the format string (i.e., no file name extensions are tested).

See also autoDetectImageFormat(), QImageIOHandler::canRead(), and QImageIOPlugin::capabilities().

Upstream PySide2 reference signatures (binding differences may apply):

setAutoDetectImageFormat(self, enabled: bool) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setAutoDetectImageFormat

setAutoTransform

setAutoTransform(enabled: bool) -> None

X.setAutoTransform(enabled)

Supplemental documentation: Qt 5 reference:

void QImageReader::setAutoTransform(bool enabled)

Determines that images returned by read() should have transformation metadata automatically applied if enabled is true.

This function was introduced in Qt 5.5.

See also autoTransform(), transformation(), and read().

Upstream PySide2 reference signatures (binding differences may apply):

setAutoTransform(self, enabled: bool) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setAutoTransform

setBackgroundColor

setBackgroundColor(color: Any) -> None

X.setBackgroundColor(color)

Supplemental documentation: Qt 5 reference:

void QImageReader::setBackgroundColor(const QColor \&color)

Sets the background color to color. Image formats that support this operation are expected to initialize the background to color before reading an image.

This function was introduced in Qt 4.1.

See also backgroundColor() and read().

Upstream PySide2 reference signatures (binding differences may apply):

setBackgroundColor(self, color: PySide2.QtGui.QColor) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setBackgroundColor

setClipRect

setClipRect(rect: Any) -> None

X.setClipRect(rect)

Supplemental documentation: Qt 5 reference:

void QImageReader::setClipRect(const QRect \&rect)

Sets the image clip rect (also known as the ROI, or Region Of Interest) to rect. The coordinates of rect are relative to the untransformed image size, as returned by size().

See also clipRect(), setScaledSize(), and setScaledClipRect().

Upstream PySide2 reference signatures (binding differences may apply):

setClipRect(self, rect: PySide2.QtCore.QRect) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setClipRect

setDecideFormatFromContent

setDecideFormatFromContent(ignored: bool) -> None

X.setDecideFormatFromContent(ignored)

Supplemental documentation: Qt 5 reference:

void QImageReader::setDecideFormatFromContent(bool ignored)

If ignored is set to true, then the image reader will ignore specified formats or file extensions and decide which plugin to use only based on the contents in the datastream.

Setting this flag means that all image plugins gets loaded. Each plugin will read the first bytes in the image data and decide if the plugin is compatible or not.

This also disables auto detecting the image format.

See also decideFormatFromContent().

Upstream PySide2 reference signatures (binding differences may apply):

setDecideFormatFromContent(self, ignored: bool) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setDecideFormatFromContent

setDevice

setDevice(device: Any) -> None

X.setDevice(device)

Supplemental documentation: Qt 5 reference:

void QImageReader::setDevice(QIODevice *device)

Sets QImageReader's device to device. If a device has already been set, the old device is removed from QImageReader and is otherwise left unchanged.

If the device is not already open, QImageReader will attempt to open the device in QIODevice::ReadOnly 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/qimagereader.html#setDevice

setFileName

setFileName(fileName: str) -> None

X.setFileName(fileName)

Supplemental documentation: Qt 5 reference:

void QImageReader::setFileName(const QString \&fileName)

Sets the file name of QImageReader to fileName. Internally, QImageReader will create a QFile object and open it in QIODevice::ReadOnly mode, and use this when reading images.

If fileName does not include a file extension (e.g., .png or .bmp), QImageReader will cycle through all supported extensions until it finds a matching file.

See also fileName(), setDevice(), and supportedImageFormats().

Upstream PySide2 reference signatures (binding differences may apply):

setFileName(self, fileName: str) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setFileName

setFormat

setFormat(format: Any) -> None

X.setFormat(format)

Supplemental documentation: Qt 5 reference:

void QImageReader::setFormat(const QByteArray \&format)

Sets the format QImageReader will use when reading images, to format. format is a case insensitive text string. Example:

QImageReader reader;
reader.setFormat("png"); // same as reader.setFormat("PNG");

You can call supportedImageFormats() for the full list of formats QImageReader 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/qimagereader.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/qimagereader.html#setGamma

setQuality

setQuality(quality: int) -> None

X.setQuality(quality)

Supplemental documentation: Qt 5 reference:

void QImageReader::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) decoding execution time. This function sets the level of that tradeoff for image formats that support it.

In case of scaled image reading, the quality setting may also influence the tradeoff level between visual quality and execution speed of the scaling algorithm.

The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low visual quality) to 100 (high visual quality).

This function was introduced in Qt 4.2.

See also quality() and setScaledSize().

Upstream PySide2 reference signatures (binding differences may apply):

setQuality(self, quality: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setQuality

setScaledClipRect

setScaledClipRect(rect: Any) -> None

X.setScaledClipRect(rect)

Supplemental documentation: Qt 5 reference:

void QImageReader::setScaledClipRect(const QRect \&rect)

Sets the scaled clip rect to rect. The scaled clip rect is the clip rect (also known as ROI, or Region Of Interest) that is applied after the image has been scaled.

See also scaledClipRect() and setScaledSize().

Upstream PySide2 reference signatures (binding differences may apply):

setScaledClipRect(self, rect: PySide2.QtCore.QRect) -> None

Source: https://doc.qt.io/archives/qt-5.15/qimagereader.html#setScaledClipRect