PDA

View Full Version : check image is valid



mero
11th November 2011, 21:21
Hi,

How can I fast check is jpg image is valid ?

There is
QImage(strImagePath).isNull() but I'm not sure is this the fastest way to check is image valid...

wysota
11th November 2011, 22:28
What do you consider a "valid" image?

mero
11th November 2011, 22:36
sometimes I have question mark in QWebView when jpg file is not fully downloaded in another thread.
thats why I need fast check if jpg file is valid/correct

wysota
12th November 2011, 02:15
It still doesn't explain what you mean by "valid". That it has a valid JPEG header or that it contains valid image data? If the former then you can check the file for the header, if the latter then either load the picture and look at it or analyze it and make sure all data is there (i.e. that the file is not truncated).