Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQt missing SVG, JPG, TIFF and other support in QImageReader #131

Closed
3five8 opened this issue Jun 16, 2014 · 31 comments
Closed

PyQt missing SVG, JPG, TIFF and other support in QImageReader #131

3five8 opened this issue Jun 16, 2014 · 31 comments

Comments

@3five8
Copy link

3five8 commented Jun 16, 2014

The pyqt available through conda install pyqt only supports the following.

print QtGui.QImageReader.supportedImageFormats()
[PyQt4.QtCore.QByteArray('bmp'), PyQt4.QtCore.QByteArray('pbm'), PyQt4.QtCore.QByteArray('pgm'), PyQt4.QtCore.QByteArray('png'), PyQt4.QtCore.QByteArray('ppm'), PyQt4.QtCore.QByteArray('xbm'), PyQt4.QtCore.QByteArray('xpm')]

The Qt4 documentation list several more.

  • BMP Windows Bitmap
  • GIF Graphic Interchange Format (optional)
  • JPG Joint Photographic Experts Group
  • JPEG Joint Photographic Experts Group
  • MNG Multiple-image Network Graphics
  • PNG Portable Network Graphics
  • PBM Portable Bitmap
  • PGM Portable Graymap
  • PPM Portable Pixmap
  • TIFF Tagged Image File Format
  • XBM X11 Bitmap
  • XPM X11 Pixmap
  • SVG Scalable Vector Graphics
  • TGA Targa Image Format

Could this be due to missing configuration during compilation?

I am running conda 3.5.5 on Win32.

@zhangruoyu
Copy link

Here is the solution:

http://stackoverflow.com/questions/14556841/how-to-load-ico-files-in-pyqt4-from-network

from PyQt4 import QtGui, QtCore
from os import path
QtCore.QCoreApplication.addLibraryPath(path.join(path.dirname(QtCore.__file__), "plugins"))
QtGui.QImageReader.supportedImageFormats()

@Nodd
Copy link

Nodd commented Sep 25, 2014

This solution doesn't work for me, be it on PySide or PyQt4 (and even if it did, it should not be necessary).

@avalentino
Copy link

Same problem here.
Maybe this issue can be fixed installing a proper qt.conf (see also #66 and #138).

@ccordoba12
Copy link

@Nodd could you test if this is fixed in the latest packages provided by conda?

@jepebe
Copy link

jepebe commented Jun 27, 2016

On OSX the latest version of PyQt4 does not have JPEG/JPG.

@ccordoba12
Copy link

The plugins location has changed. Now it is at

/<path-to-Anaconda-or-env>/lib/qt4/plugins

Please verify that it's working for you.

@jepebe
Copy link

jepebe commented Jun 28, 2016

These are the files in /anaconda/lib/qt4/plugins

libqgif.dylib
libqico.dylib
libqjpeg.dylib
libqmng.dylib
libqsvg.dylib
libqtga.dylib
libqtiff.dylib

While this is the output of print(QImageReader.supportedImageFormats())

[PyQt4.QtCore.QByteArray('bmp'), PyQt4.QtCore.QByteArray('gif'), PyQt4.QtCore.QByteArray('ico'), PyQt4.QtCore.QByteArray('mng'), PyQt4.QtCore.QByteArray('pbm'), PyQt4.QtCore.QByteArray('pgm'), PyQt4.QtCore.QByteArray('png'), PyQt4.QtCore.QByteArray('ppm'), PyQt4.QtCore.QByteArray('svg'), PyQt4.QtCore.QByteArray('svgz'), PyQt4.QtCore.QByteArray('tga'), PyQt4.QtCore.QByteArray('tif'), PyQt4.QtCore.QByteArray('tiff'), PyQt4.QtCore.QByteArray('xbm'), PyQt4.QtCore.QByteArray('xpm')]

@jepebe
Copy link

jepebe commented Jun 28, 2016

I also added these paths with the same result.

QCoreApplication.addLibraryPath("%s/anaconda/lib/qt4" % user_path)
QCoreApplication.addLibraryPath("%s/anaconda/lib/qt4/plugins" % user_path)
QCoreApplication.addLibraryPath("%s/anaconda/lib/qt4/plugins/imageformats" % user_path)

@ccordoba12
Copy link

So the only unsupported one is Jpeg, but I don't know why as we provide the Qt plugin for it :-/

@jepebe
Copy link

jepebe commented Jul 4, 2016

Anything else I can do to debug this?

@brylie
Copy link

brylie commented Jul 6, 2016

I am unable to render SVG images in Orange3 when Anaconda is installed. Here are my available image formats:

>>> print("PyQt4 installed in", os.path.dirname(PyQt4.__file__))
PyQt4 installed in /home/brylie/anaconda3/lib/python3.5/site-packages/PyQt4
>>> print("Qt4 library paths", QApplication.libraryPaths())
Qt4 library paths []
>>> print([bytes(f).decode("ascii") for f in QImageReader.supportedImageFormats()])
['bmp', 'pbm', 'pgm', 'png', 'ppm', 'xbm', 'xpm']

@brylie
Copy link

brylie commented Jul 7, 2016

As a previous comment suggested, I looked under the anaconda3 folder in my home directory. I found the following:

  • ~/anaconda3/lib/qt4/plugins/iconengines
    • libqsvgicon.so
  • ~/anaconda3/lib/qt4/plugins/imageformats
    • libqgif.so
    • libqjpeg.so
    • libqsvg.so
    • libqtiff.so
    • libqico.so
    • libqmng.so
    • libqtga.so

I notice SVG in both locations, but SVG is not listed in QImageReader.supportedImageFormats():

>>> print([bytes(f).decode("ascii") for f in QImageReader.supportedImageFormats()])
['bmp', 'pbm', 'pgm', 'png', 'ppm', 'xbm', 'xpm']

@astaric
Copy link

astaric commented Jul 7, 2016

I am experiencing the same problem with anaconda 4.1.6 on OSX (missing SVG support).

I can work around the issue by moving the qt.conf from anaconda/bin to anaconda/python.app/Contents/Resources.

@brylie
Copy link

brylie commented Jul 7, 2016

Thanks @astaric. I don't have a python.app folder. My folder structure, on Ubuntu 16.04, looks like:

  • ~/anaconda3
    • bin/
    • conda-meta
    • envs/
    • etc/
    • Examples/
    • include/
    • lib/
    • LICENSE.txt
    • pkgs/
    • share/
    • ssl/
    • var/

To which folder should I copy qt.conf?

@ccordoba12
Copy link

ccordoba12 commented Jul 7, 2016

@astaric, thanks a lot for the suggestion. I'll add it to our next build of Qt4 :-)

@ccordoba12
Copy link

@brylie, you need to install python.app first:

conda install python.app

@brylie
Copy link

brylie commented Jul 8, 2016

Thanks @ccordoba12. Here is the output of that command:

Error: Package missing in current linux-64 channels: 
  - python.app

Close matches found; did you mean one of these?

    python.app: python-snappy, python-ldap, python

You can search for packages on anaconda.org with

    anaconda search -t conda python.app

When searching for the python.app, three packages appear:

anaconda search -t conda python.app
Using Anaconda Cloud api site https://api.anaconda.org
Run 'anaconda show <USER/PACKAGE>' to get more details:
Packages:
     Name                      |  Version | Package Types   | Platforms      
     ------------------------- |   ------ | --------------- | ---------------
     aetrial/python.app        |          | conda           | osx-64         
     anaconda/python.app       |      1.2 | conda           | osx-64         
     asmeurer/python.app       |      1.2 | conda           | osx-64         
Found 3 packages

Note, I am on GNU/Linux. Is the python.app necessary?

@ccordoba12
Copy link

python.app is only available for Mac.

@JPFrancoia
Copy link

Hi, I'm jumping into the issue.

On a fresh install of Mac OS X El capitan, fresh install of anaconda3 (conda 4.2.12), fresh install of pyqt4, I don't have the directory ~/anaconda3/lib/qt4/, just ~/anaconda3/lib/.

Also, I tried @astaric 's solution: I installed python.app, moved qt.conf from anaconda/bin to anaconda/python.app/Contents/Resources, but my program still can't load jpeg images.

What can I try ?

@JPFrancoia
Copy link

JPFrancoia commented Nov 21, 2016

Should I open a new issue ?

@astaric , could you post the content of the qt.conf file you put in anaconda/python.app/Contents/Resources please ?

@ccordoba12
Copy link

We're probably not going to update Qt4/PyQt4 anymore.

Is this problem still present in Qt5?

@JPFrancoia
Copy link

JPFrancoia commented Nov 21, 2016

I don't know, but I can check if you want. For now, I have a huge software developed with PyQt4 and I don't intend to port it to qt5 anytime soon. Is there a way/tweak I can make PyQt4 work for now ?

First, is it normal I don't have the directories as the others ? I don't have the directory ~/anaconda3/lib/qt4/, for example.

@ccordoba12
Copy link

I don't know, but I can check if you want.

I checked it, and our Qt5 packages support all these formats out of the box.

I don't intend to port it to qt5 anytime soon

You could use qtpy to quite easily do the porting job. That's a compatibility library to work seamlessly with PyQt4 and PyQt5 in the same codebase.

Is there a way/tweak I can make PyQt4 work for now ?

I don't think so, it seems to have this we'd need to recompile Qt4 and PyQt4. You have two alternatives here:

  1. You could hire us to add these formats for Qt4.
  2. You could experiment in the conda-forge qt feedstock to add these formats. Feedstocks are repos of conda packages that are built automatically in CI services. However, that feedstock only builds Linux packages.

@dzimbeck
Copy link

dzimbeck commented Dec 2, 2016

This is totally crazy 2016 and PyQt4 has problems with something as basic as a JPEG. We should be in flying cars by now, what is this.

I'm having the same issue. Deployed software and on some platforms the image dlls refuse to load with a frozen executable.

Had to use Pillow to convert the images manually to PNG. That works but not a great solution.

Can anyone confirm Qt5 works with JPEG?

@JPFrancoia
Copy link

Yes, Qt5 works with jpeg. However, Qt4 is not to blame here. I can work with it on linux and windows without problem.

@mingwandroid
Copy link

mingwandroid commented Dec 2, 2016

This is totally crazy 2016 and PyQt4 ..

Qt5 is 4 years old now. The amount of code change required to adapt Qt4 code to work on Qt5 is minimal: https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5. I expect PyQt and qtpy make the transition even easier. Please do your project(s) a favour and make those changes.

@dzimbeck
Copy link

dzimbeck commented Dec 2, 2016

Actually Qt4 is to blame. When you deploy the software as a frozen executable some systems will not correctly load the plugins. This is true for pyinstaller and others. It depends on the system. Deployed my applications work on 99% of the systems. But some users can't get jpegs because the plugin won't load. This is a known issue. Hooks don't work, even directly loading the plugin in the source code doesn't work. It simply will not load. I've spent two days on this bug. Had to convert every jpg to png.

@JPFrancoia
Copy link

Is it because the system doesn't properly loads the plugin, or because anaconda puts it in the wrong place ?

@ccordoba12
Copy link

ccordoba12 commented Dec 2, 2016

Is it because the system doesn't properly loads the plugin, or because anaconda puts it in the wrong place ?

This just happens because we (i.e. Continuum) don't provide those plugins, that's all.


To restate our position: Qt4 is not supported by us anymore. You're very welcome to hire us to add support for it in your projects if that's a priority for you.

If that alternative is not suitable, you have the option of sending a pull request against the qt conda-forge feedstock for all operating systems. Those recipes are the same ones we used internally, so we could pick your work and provide new packages for Qt4 on Continuum's side.

I hope our position is clear now.

@JPFrancoia
Copy link

It's not a problem for me anymore. I ported my code to Qt5 (it just required 2 days of work, that's not much). Now jpeg images load properly, but I have other issues with freezing my app (but it's another story).

If you don't support pyqt4 anymore, shouldn't we close the issue as "won't fix" ?

@mingwandroid
Copy link

Won't fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests