The image module

A page that can display an image, loaded using QImage.

ImagePages are instantiated quite fast. The image is only really loaded on first display.

class ImageContainer(image)[source]

Bases: object

Represent an image, is shared among copies of the “same” Page.

class ImageLoader(source, autoTransform=True)[source]

Bases: qpageview.image.ImageContainer

Represent an image loaded from a file or IO device.


Return the size of the image.

If the image can’t be loaded, a null size is returned. The resulting value is cached.


Load and return the image.

If clip is given, it should be a QRect describing the area to load.

class ImagePage(container, renderer=None)[source]


A Page that displays an image in any file format supported by Qt.

autoTransform = True
dpi = 96
classmethod load(filename, renderer=None)[source]

Load the image and yield one ImagePage instance if loading was successful.

classmethod fromImage(image, renderer=None)[source]

Instantiate one ImagePage from the supplied QImage.

As the image is kept in memory, it is not advised to instantiate many Page instances this way. Use load() for images on the filesystem. The image must be valid, and have a size > 0.

print(painter, rect=None, paperColor=None)[source]

Paint a page for printing.

image(rect=None, dpiX=None, dpiY=None, paperColor=None)[source]

Return a QImage of the specified rectangle.


Return the group the page belongs to.

This could be some document structure, so that different Page objects could refer to the same graphical contents, preventing double caching.

This object is used together with the value returned by ident() as a key to cache the page. The idea is that the contents of the page are uniquely identified by the objects returned by group() and ident().

This way, when the same document is opened in multiple page instances, only one copy resides in the (global) cache.

By default, the page object itself is returned.


Return an object that should be locked when rendering the page.

Page are guaranteed not to be rendered at the same time when they return the same mutex object. By default, None is returned.

renderer = <qpageview.image.ImageRenderer object>
class ImageDocument(sources=(), renderer=None)[source]

Bases: qpageview.document.MultiSourceDocument

A Document representing a group of images.

A source may be a filename, a QIODevice or a QImage.


alias of qpageview.image.ImagePage


Implement this method to create and yield the pages.

This method is only called once. After altering filename,-s or source,-s, or invalidate(), it is called again.

class ImageRenderer(cache=None)[source]

Bases: qpageview.render.AbstractRenderer

draw(page, painter, key, tile, paperColor=None)[source]

Draw the specified tile of the page (coordinates in key) on painter.