Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt open image from file - how to know image size

Tags:

c++

file

image

qt

I am getting image file with QFileDialog. Image can be in different standard image file extensions. How can I get image size (width and height)?

like image 492
ManInTheHood Avatar asked Dec 03 '22 00:12

ManInTheHood


1 Answers

If you only need the size of the image, but not the image itself, it is better to use the QImageReader. As described in the wiki, not all image data is loaded. This procedure should be much faster:

QImageReader reader("image.png");
QSize sizeOfImage = reader.size();
int height = sizeOfImage.height();
int width = sizeOfImage.width();
like image 146
Horst Avatar answered Dec 21 '22 15:12

Horst