Perl Guy has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know how to check the type of image file returned by an external web server? Where the only differences would be the file size. Below is an HTML code example:

a href='http://www.keen.com/calls/PT_interimcall.asp?sid=5350849'><img + border=0 src='http://www.keen.com/calls/callimage.asp?sid=5350849&Im +ageType=1'></a>

The image returned by the img src= would be either 'available', 'busy', 'away' etc. The only difference I can determine is filesize of the image returned by the web server based on the status of the caller.

I'd like to check the availablility of multiple accounts to market the 'available' advisors.

If there is a *different* way to find out the status it would be greatly appreciated to be pointed in that direction as well.

I would greatly appreciate it if someone could point me in the right direction as to how to gather this information from the remote server.

Thank you,
Jason

Janitored by davido: Cleaned up formatting / code tags to match intent of original post.

  • Comment on How do I check the Status of an image file created from a script on another web server?
  • Download Code

Replies are listed 'Best First'.
Re: How do I check the Status of an image file created from a script on another web server?
by samtregar (Abbot) on Jan 01, 2005 at 23:43 UTC
    I can think of two options:

    1. Save copies of all the possible images returned. Use Digest::MD5 to get a signature for each. When you get an image from the server compare its MD5 to the MD5s of the known files. If you get a match then you know what you got.
    2. Optical Character Recognition (OCR). There are lots of programs available that will look at an image and try to figure out what the letters in it say. Some are very clever.

    I'd try the first option and only fall back to the second if the image may change without warning. It's probably much harder to get working and still might fail if the image becomes harder to decipher.

    -sam

      Thanx for your input Sam.

      Does anyone know how to grab the image from the external server, like in my example and bring it into a PERL Script do grab the Digest::MD5 signature.

      Thanx,
      Jason
        use LWP::Simple; use Digest::MD5 qw(md5); print md5(get("http://promote.pair.com/i/pair-banner-current.gif"));