Will Qpixmap in MacQt6 support webp images in the future?

I used Webp images for Qpixmap in my add-on, but it didn’t work only in MacQt6.(WebEnginView is fine, only Qpixmap does not work)

Qpixmap webp works properly on Anki-MacQt5, native PyQt6 and PyQt5 on Mac devices, Anki for Windows, Anki for Linux.(Only on Anki Qt6 for Mac does not work.)

I have tried newer and older Anki for Mac qt6 versions but not working on any of them.

  • webp sample(Qpixmap)

I used this code to check for Qt support.

from aqt import QImageReader
print(QImageReader.supportedImageFormats())
print(QImageWriter.supportedImageFormats())

Did you explicitly specify the format of the image in the QPixmap constructor or load() method? The Qt documentation says that if not specified, the format is guessed from the file header. Or, this post says it is first guessed from the file extension. In any case, if your code does not specify the format, then the format may not be guessed correctly.

1 Like

Please try running Anki from Python and see if the issue exists outside of the packaged version.

https://betas.ankiweb.net/#via-pypipip

Thanks for the info, I didn’t know about it so I tried this, but there seems to be no change.

pixmap = QPixmap(image_path, format='webp')

When I use QImageReader.supportedImageFormats() with MacQt6, Webp doesn’t exist, so it seems like there is no support.(but I’m not familiar with it, so I’m not exactly sure.)

I have tried it, it seems the webp image is properly displayed on Anki for Mac outside of the package.

I have tried several devices like this.

  • ◯[ MacQt6 non-package ] Version 23.12.1 Python 3.12.1 Qt 6.6.1 PyQt 6.6.1
  • ▲[ MacQt6 package ]Version ⁨23.12.1 ⁩Python 3.9.15 Qt 6.5.3 PyQt 6.5.3
  • ▲[ MacQt6 package ] Version 23.12 Python 3.9.15 Qt 6.6.1 PyQt 6.6.0
  • ◯[ MacQt5 package ]Version 23.12.1 Python 3.9.15 Qt 5.14.2 PyQt 5.14.1
  • ◯[ WinQt6 packege ] Version ⁨23.12.1 Python 3.9.15 Qt 6.6.1 PyQt 6.6.1
  • ◯[ UbuntuQt6 ] Version ⁨2.1.66 Python 3.9.15 Qt 6.5.0 PyQt 6.5.0

This is a simple add-on to reproduce the problem (webp image will pop up when Anki starts, download the .ankiaddon file from the download icon in the upper right corner).

Thank you, I will try fix this when we update to Qt 6.6.2.

1 Like

Thank you very much. I read the Qt documentation and found that additional image formats such as webp are provided by the Qt Image Formats module.

So I thought that only MacQt6 might not have additional plugins set up, but I have never done a build, so I don’t know much more than that.(or this info may not be relevant at all, I can only read python.)

I bundled dwebp with add-on and called it in a custom Qpixmap class with subprocess and converted it to png so I can load webp.

It is slower to load than native Qpixmap(x2 to x3), but it can support old MacQt6, so I will use it with this.(In short, if the Mac does not support webp, use dwebp, if it supports it, use the native Qpixmap.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.