Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy image from website 2

Status
Not open for further replies.

c1utch

MIS
Joined
Jan 23, 2002
Messages
151
Location
US
I'd like to copy a single image from a website (local weather radar image) and save it to network share on my network. The radar image ( is in .gif format, but I'd like to save it as a bitmap and overwrite the old file each time. Is there a way to do this with a simple .vbs script? I'm going to eventually set this script up as a scheduled event so this is an automatated process.

Chris
 
[tt]dim surl,slocal,oxmlhttp,ostream

[green]surl="slocal="h:\test\cad.gif"[/green]

on error resume next
set oxmlhttp=createobject("msxml2.xmlhttp")
if err.number<>0 then
wscript.echo "msxml2.xmlhttp not installed. Operation aborted."
wscript.quit(1)
end if
with oxmlhttp
.open "get",surl,false
.send
end with
if err.number<>0 then
wscript.echo "Resource unavailable for varied reasons. Operation aborted."
set oxmlhttp=nothing : wscript.quit(2)
end if

set ostream = createobject("adodb.stream")
with ostream
.type=1 'binary
.mode=3 'read-write
.open
.write oxmlhttp.responsebody
.savetofile slocal,2 'save-create-overwrite
.close
end with
if err.number<>0 then
wscript.echo "You need ado2.5 up. Operation aborted"
else
wscript.echo "Done!" & vbcrlf & "Source : " & surl & vbcrlf & "Local : " & slocal
end if
on error goto 0
set ostream=nothing : set oxmlhttp=nothing
[/tt]
 
tsuji, a star for you. I flagged this message for notification so I could see if anyone could suggest a way to get this done. Awesome solution!

c1utch, I believe you will still need to find a command line utility you could use to convert the image from GIF to BMP. I believe you could use this:

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
When I right click on this image from a web browser, I have the ability to save it in .gif or .bmp format. With that being said, I believe I should just be able to change the following line of code:

slocal="h:\test\cad.gif"

to this:

slocal="h:\test\cad.bmp"

Definitely thumbs up tsuji!!!! This is a keeper. Since my post, I also came across the application "wget" that will do the same thing. But thanks again tsuji for all your input!!!!

Chris
 
FYI, tsuji's method is not restricted to images on websites...for anyone who has never tried this before.


--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
That is an old post and I like that one better since it is in a Sub.

If it is not already, you might just make it an FAQ....just a thought.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top