Image() from URL: Discovering Redirects

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
mankyd

Image() from URL: Discovering Redirects

Post by mankyd »

Programming in Magick++, I've got a program that is loading images from a url:

Code: Select all

try {
  source_img = new Image(get_url());
} catch (Exception &e) {
  throw; //handled in a different part of the program
}
99 times out of 100, this works just peachy and everybody is happy. Every once and awhile, however, the URL I am trying to open actually redirects my code to a "missing file" image. It still opens just fine, it's just not the image I want.

I was looking at http://www.imagemagick.org/Magick++/Exception.html and noticed that there is a class of "warning" exceptions, but none of them seem to cover this case. Is there any way I can detect when the url was a redirect?
Post Reply