How do I judge a file's type?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
soulmachine

How do I judge a file's type?

Post by soulmachine »

Magick::Image test1("test.txt");//will crash when running
Magick::Image test2;
test2.read("test.txt");//will also crash

I notise that read(std::string& imgSpec) does not return a value,so I cannot control my program to ignore files which are not images.

Is there any way to known a file's type, or just tell me whether a file is a image?
thanks :)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How do I judge a file's type?

Post by magick »

We tried your code and it returned an exception as expected. We're using ImageMagick 6.3.8-0.
Post Reply