Daveloper
Daveloper

Reputation: 646

How to get if the file is type of JPEG with jpeglib.h

I would like to ask you if there is any way how to get information(bool value) if the file is jpeg.

I solved it in png like this:

bool isPng = !png_sig_cmp(reinterpret_cast<png_const_bytep>(header), 0, number);

I tried to search on the internet and read the documentation of jpeglib, but didn't solve it.

Thank you for your answers.

Upvotes: 0

Views: 182

Answers (1)

Richard Nixon
Richard Nixon

Reputation: 847

If you read the first few bytes of the file you should see the JFIF characters in a jpeg. Using jpeglib you can attempt to read the header data and fail on that.

Upvotes: 2

Related Questions