Constantine
Constantine

Reputation: 83

Qt/QML. A way to learn image size without load

I have a set of images (url addresses). Some of them are of acceptable size, but some are too big. When I load it, the app crashes because of big images.

Is there a way to get the image size (megabytes) before loading it? This way I can remove large images from the list, and avoid loading them.

Upvotes: 2

Views: 509

Answers (1)

m.s.
m.s.

Reputation: 16334

If the server where the images are located supports it, you can issue a HEAD request. This can be done in Qt using e.g. QNetworkAccessManager::head.

It should also be possible in QML/Javascript, see HTTP HEAD Request in Javascript/Ajax?.

Upvotes: 2

Related Questions