Page 1 of 1

Image() from URL: Discovering Redirects

Posted: 2007-02-01T09:15:25-07:00
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?