[PyQt] ANN: qimage2ndarray - converting between QImages and numpy.ndarrays

Phil Thompson phil at riverbankcomputing.com
Wed Dec 2 17:51:18 GMT 2009

On Wed, 2 Dec 2009 18:42:37 +0100, Hans Meine
<meine at informatik.uni-hamburg.de> wrote:
> Hi,
> I have just uploaded a first release of qimage2ndarray, a tiny python 
> extension for quickly converting between QImages and numpy.ndarrays
> (in both directions).  These are very common tasks when programming e.g. 
> scientific visualizations in Python using PyQt4 as the GUI library.
> Similar code was found in Qwt and floating around on mailing lists,
> but qimage2ndarray has the following unique feature set:
> * Supports conversion of scalar and RGB data, with arbitrary dtypes
>   and memory layout, with and without alpha channels, into QImages
>   (e.g. for display or saving using Qt).
> * Using a tiny C++ extension, qimage2ndarray makes it possible to
>   create ndarrays that are *views* into a given QImage's memory.
>   This allows for very efficient data handling and makes it possible
>   to modify Qt image data in-place (e.g. for brightness/gamma or alpha
>   mask modifications).
> * qimage2ndarray is stable and unit-tested:
>   * proper reference counting even with views (ndarray.base points to
>     the underlying QImage)
>   * handles non-standard widths and respects QImage's 32-bit row
>     alignment
> * Masked arrays are also supported and are converted into QImages
>   with transparent pixels.
> * Supports value scaling / normalization to 0..255 for convenient
>   display of arbitrary NumPy arrays.
> The extension is open source, BSD-licensed, and available via PyPI or
> I hope this is useful to many of you and look forward to your feedback,
>   Hans
> PS: Now that I am announcing this, I suddenly have the feeling that I
> should 
> have talked with some lawyer (or Phil) about possible license issues
> because 
> of PyQt.  I really hope there will not turn out to be problems with this.

There is no license issue.


More information about the PyQt mailing list