Python study notes-Qimage

1. Get the length and width of Qimage

from PyQt5 import QtGui

qimage = QtGui.QImage('C:/Users/wxscn/Desktop/test.jpg')
# 直接打印rect得不到长宽
rect = qimage.rect()
# 第1种获取长宽的方法
w = rect.width()
h = rect.height()
# 第2种获取长宽的方法
w_ = qimage.width()
h_ = qimage.height()
print(rect, (w, h), (w_, h_))

Operation result: PyQt5.QtCore.QRect(0, 0, 536, 868) (536, 868) (536, 868)

Guess you like

Origin blog.csdn.net/wxsy024680/article/details/114894277