Question about comparing Remote image with Local one

V

Vijoy Varghese

Hello Group,

My final goal is to show a green/red gif image on my webpage when I am
available on yahoo chat. Yes for this I could have used the url
provided by yahoo
http://opi.yahoo.com/online?u=xxxx&m=g&t=2, where xxxx is my yahoo
userid. But the images yahoo print wont match with my webpage's
colors. So I want to display a custom one. Now I know some Perl and I
decided to give it a try.

I used the LWP module to get the image (either online image/ offline
image) from yahoo.
______
use LWP::UserAgent;
use LWP;
use CGI;
my $q=new CGI;
my $browser = LWP::UserAgent->new;

my @ns_headers = (
'User-Agent' => 'Mozilla/4.76 [en] (Win98; U)',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
image/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
);

my $url='http://opi.yahoo.com/online?u=vishnutp3&m=g&t=2';
$res = $browser->get($url, @ns_headers);

print $q->header(-header=>'text/html');
print $res->content;
______

Now, I have the image from yahoo through my script. Now what I want is
to see if the image is that of 'online_status' or 'offline_status'.
And according to that, display my custom 'online/offline' image.

For this, what I can do is to get the two images from yahoo, when my
id is offline and when my id is online and save it.
Then when ever the script is called, compare the real_time image from
yahoo to the ones saved and take the decision.

Now, my question is, Which is the best way to compare the remote image
with the one I have on my server?

Can I embbed the data of the image on my server to the perl program,
will this be efficient(because no read from file is required)? I tried
everything using trial and error methods, but seems like the
difference between 'ascii' and 'binary' mode is doing the trick and I
am not able to compare the image from remote computer(yahoo) and the
image on myserver.
Can some one guide me, or give me pointers to some online resource
which will help me to solve the problem with maximum efficiency?

Thankyou for all helps in advance,

Regards
Vijoy Varghese
 
N

Neil Shadrach

Vijoy said:
Can some one guide me, or give me pointers to some online resource
which will help me to solve the problem with maximum efficiency?

Generate some sort of checksum from the two images and store that in your program for comparison?

perl -e 'use Digest::MD5; if ( open(my $h, "/tmp/online.gif") )
{ my $m=Digest::MD5->new; $m->addfile($h); print $m->hexdigest,"\n";}'
 
A

Anno Siegel

Vijoy Varghese said:
Hello Group,

My final goal is to show a green/red gif image on my webpage when I am
available on yahoo chat. Yes for this I could have used the url
provided by yahoo
http://opi.yahoo.com/online?u=xxxx&m=g&t=2, where xxxx is my yahoo
userid. But the images yahoo print wont match with my webpage's
colors. So I want to display a custom one. Now I know some Perl and I
decided to give it a try.

I used the LWP module to get the image (either online image/ offline
image) from yahoo.

[snip irrelevant code]
Now, I have the image from yahoo through my script. Now what I want is
to see if the image is that of 'online_status' or 'offline_status'.
And according to that, display my custom 'online/offline' image.

For this, what I can do is to get the two images from yahoo, when my
id is offline and when my id is online and save it.
Then when ever the script is called, compare the real_time image from
yahoo to the ones saved and take the decision.

Now, my question is, Which is the best way to compare the remote image
with the one I have on my server?

This sounds like a rather strange plan.

Use MD5 checksums to compare the files, don't compare the whole content.
See Digest::MD5 for how to.

Anno
 
A

A. Sinan Unur

(e-mail address removed) (Vijoy Varghese) wrote in
Hello Group,

My final goal is to show a green/red gif image on my webpage when I am
available on yahoo chat. Yes for this I could have used the url
provided by yahoo
http://opi.yahoo.com/online?u=xxxx&m=g&t=2, where xxxx is my yahoo
userid.

How about using the information on http://profiles.yahoo.com/user_id ?

There, your online status is indicated by an embedded image: online.gif or
offline.gif depending on your status. The image's alt text is IM. So your
script can just check the name of the image file to determine your online
status. Just an idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top