PySide2/QPixmap unable to read Jpeg

Hi,

I’m running into a curious issue with a tool/package that I’m developing for RV. I’ve just moved over to PySide2 from PySide, but I’ve found that now I’m unable to read .jpg files for use in my UI - which I was able to do before.

Simple example…

from PySide2 import QtGui

pixmap = QtGui.QPixmap("<path to some jpeg>")
print(pixmap.size())

Outside of RV, this snipper will print the dimensions of the Jpeg that I’m loading, indicating that the load was successful. Within RV, this will print (0,0), and using the QPixmap.load method will return False.

If I change the image format to .png this this works as expected.

I can’t see any documentation to suggest this is intended behaviour, so assume it’s a bug. Can anyone confirm this behaviour and/or suggest a workaround?

Many thanks!

1 Like

Hello Philboltt,

I just tried it with RV 7.6.1 on all 3 supported platforms and it seems to be working:

$ ./RV.app/Contents/MacOS/py-interp
Python 2.7.14 (default, Nov 15 2017, 12:54:18)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

from PySide2 import QtGui
pixmap = QtGui.QPixmap("/Users/labergb/Downloads/i_tonya.jpeg")
print(pixmap.size())
PySide2.QtCore.QSize(970, 444)

[rv-centos7-x86-64-7.6.1]$ ./bin/py-interp
Python 2.7.11 (default, Feb 7 2020, 14:56:55)
[GCC 6.3.1 20170216 (Red Hat 6.3.1-3)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

from PySide2 import QtGui
pixmap = QtGui.QPixmap("/home/labergb/Downloads/i_tonya.jpeg")
print(pixmap.size())
PySide2.QtCore.QSize(970, 444)

c:\toTest\rv-win64-x86-64-7.6.1\bin>py-interp.exe
Python 2.7.11 (default, Feb 11 2020, 21:39:39) [MSC v.1916 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

from PySide2 import QtGui
pixmap = QtGui.QPixmap(“C:\Users\admin_bernard\Downloads\i_tonya.jpeg”)
print(pixmap.size())
PySide2.QtCore.QSize(970, 444)


Could it possibly be a path issue?
Like on Windows, at first I used the single backslash and without the double backslash, I was getting the PySide2.QtCore.QSize(0,0) since the file could not be located.

I hope this helps,

Bernie

2 Likes