How to check if image can be read

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
Senos

How to check if image can be read

Post by Senos »

Hello Wonderful ImageMagick World :)

Is there any Magick++ method that reads image from a location (C:/images/test.jpg) and returns bool if the image is found ?

I have an if statement and I would like to know if the image can be read before I proceed.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to check if image can be read

Post by anthony »

Add -regard-warnings and check the status result of your image processing.

In a script this is typically to read the image into a temporary file while also extracting basic information such as image width and height.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Senos

Re: How to check if image can be read

Post by Senos »

How can such a thing implemented in c++ ?
I thought that was for command line only

Thanks for your kind reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to check if image can be read

Post by anthony »

In C++ and other API's you should be checking the error returned from the image read process and act accordingly!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply