imageToArray AttributeError: 'NoneType' object has no attribute 'setsize'

30 views
Skip to first unread message

TerenceSkill

unread,
May 31, 2019, 5:34:57 PM5/31/19
to pyqtgraph
Hi everybody,

I was trying to load and display a big image with a resolution over 20000x20000 and got an AttributeError for the imageToArray function.
After reducing the resolution it was working without any error, so I divided the image into multiple small images.

With the following code i still get the AttributeError shown below.
The error does not always occur at the same time. It varies between image 14 and 18.

I use pyqtgraph version 0.10.0 and PyQt5 version 5.12.2.

Thanks for your help.

from PyQt5 import QtGui
import pyqtgraph as pg

n = 1
while n <= 25:
    print(n)
    imgfile = str(n)
    img = QtGui.QImage(imgfile)
    img = img.convertToFormat(QtGui.QImage.Format_ARGB32_Premultiplied)
    imgArray = pg.imageToArray(img, copy=True)

    if n == 1:
        imgArrays = [imgArray]
    else:
        imgArrays.append(imgArray)
    n += 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Traceback (most recent call last):
  File "C:/Users/User/Project/test.py", line 11, in <module>
    imgArray = pg.imageToArray(img, copy=True)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\pyqtgraph\functions.py", line 1177, in imageToArray
    ptr.setsize(img.byteCount())
AttributeError: 'NoneType' object has no attribute 'setsize'

Process finished with exit code 1
Reply all
Reply to author
Forward
0 new messages