python-3.xpyqt5image-compressionqimage

PyQt5 - Load JPEG-compressed image to QImage


I have an application that displays images, using QtGui.QImage. To save space, I changed the GeoTiff compression from LZW to JPEG, but now I get the following error:

foo: JPEG compression support is not configured.
foo: Sorry, requested compression method is not configured.

I have not found anything how I can configure PyQt to understand that type of compression. Do I need a specific build or can I set it somewhere? Using Python 3.10 with PyQt5.15


Solution

  • Thanks to the comment of @musicamante, the issue could be solved simply by using:

    from PIL.ImageQt import ImageQt
    
    my_q_image = ImageQt(image_path)
    

    Then, my_q_image acts exactly like a QImage.

    Important reminder though, which I found while investigating this: PyQt5 support from PIL ends in July 2023!