I am writing small C program using Cimg graphics library and need to test that a file is an image.
I attempted to load the file/image with
CImg<unsigned char> srcimg(filename)
and catch the exemption but the cimg flattly quits with:
convert.im6: improper image header `pok.txt' @ error/bmp.c/ReadBMPImage/603.
convert.im6: no images defined `pnm:-' @ error/convert.c/ConvertImageCommand/3044.
sh: 1: gm: not found
terminate called after throwing an instance of 'cimg_library::CImgIOException'
what(): [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load() : Failed to recognize format of file 'pok.txt'.
Aborted
Of course, the file is txt, but ignoring the suffix, is there a proper way how to test this? Without involving another dependencies/libraries.
Thanks