Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Simple? How to copy WWW picture to C drive

Reply
 
Old 10-06-2008   #1 (permalink)
Zoiks


 
 

Simple? How to copy WWW picture to C drive

Hi folks,

Hopefully this is a simple one for you. I would like to copy a JPG
picture from a website on a regular basis. Any tips on how to do
this? I would prefer a vbscript or even a batch file if it can do the
job.

For example:
html:\\microsoft.com\logo1.jpg
I'd like the script to copy "logo1.jpg" to my local C drive, and
overwrite the existing image.

I can use Windows Task Scheduler to run this script on a regular basis
(a simple way for me to set this up). I'm not a programmer
(obviously) so some steps would be handy, but not required if its
easy.

Thanks
Andrew

My System SpecsSystem Spec
Old 10-06-2008   #2 (permalink)
Paul Randall


 
 

Re: Simple? How to copy WWW picture to C drive


"Zoiks" <cavalier_102@xxxxxx> wrote in message
news:74e0cbf4-6da1-4578-be07-4ef44642a814@xxxxxx
Quote:

> Hi folks,
>
> Hopefully this is a simple one for you. I would like to copy a JPG
> picture from a website on a regular basis. Any tips on how to do
> this? I would prefer a vbscript or even a batch file if it can do the
> job.
>
> For example:
> html:\\microsoft.com\logo1.jpg
> I'd like the script to copy "logo1.jpg" to my local C drive, and
> overwrite the existing image.
>
> I can use Windows Task Scheduler to run this script on a regular basis
> (a simple way for me to set this up). I'm not a programmer
> (obviously) so some steps would be handy, but not required if its
> easy.
>
> Thanks
> Andrew
Hi, Andrew
Google is your friend.
GROUPS.google.com is even better for finding stuff that may have been
discussed in a one newsgroup or a family of related newsgroups.
Go to groups.google.com; copy the following line and past it into the search
box:
working example of downloading and saving a binary file
group:*.scripting.vbscript

-Paul Randall


My System SpecsSystem Spec
Old 10-07-2008   #3 (permalink)
Joe Fawcett


 
 

Re: Simple? How to copy WWW picture to C drive

Here's a script I use, it's JavaScript but you can schedule a batch file to
call it:
CScript saveRemoteFile.js http://www.example.com/fileToSave.jpg
"C:\savedFiles\savedFile.jpg"

********************
function saveRemoteFile(From, To)
{
var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.6.0"); //Change to
version 3 if necessary
oXmlHttp.open("GET", From, false);
oXmlHttp.send();
if (oXmlHttp.status == 200)
{
var oStream = new ActiveXObject("Adodb.Stream");
oStream.type = 1; //Binary
oStream.open();
oStream.write(oXmlHttp.responseBody);
oStream.saveToFile(To, 2);
oStream.close();
}
else
{
throw new Error(oXmlHttp.statusText); //Needs improving
}
}

function main()
{
var sUrl = WScript.arguments(0);
var sTarget = WScript.arguments(1);
saveRemoteFile(sUrl, sTarget);
WScript.echo("Done.");
WScript.quit();
}

main();
***************************

--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name

"Zoiks" <cavalier_102@xxxxxx> wrote in message
news:74e0cbf4-6da1-4578-be07-4ef44642a814@xxxxxx
Quote:

> Hi folks,
>
> Hopefully this is a simple one for you. I would like to copy a JPG
> picture from a website on a regular basis. Any tips on how to do
> this? I would prefer a vbscript or even a batch file if it can do the
> job.
>
> For example:
> html:\\microsoft.com\logo1.jpg
> I'd like the script to copy "logo1.jpg" to my local C drive, and
> overwrite the existing image.
>
> I can use Windows Task Scheduler to run this script on a regular basis
> (a simple way for me to set this up). I'm not a programmer
> (obviously) so some steps would be handy, but not required if its
> easy.
>
> Thanks
> Andrew

My System SpecsSystem Spec
Old 10-07-2008   #4 (permalink)
Zoiks


 
 

Re: Simple? How to copy WWW picture to C drive

Cool, thanks Joe it worked very well.
Part two to the question now

Do you know a way to resize the image after (or while) saving the file
to the local PC?

When I checked the properties of the image on the web site, the image
size was about 400x300. When I ran your script it saved the file at
about 640x400. My goal is to get it down to 300x200 +/-.
Thanks for the tips so far!!
My System SpecsSystem Spec
Old 10-07-2008   #5 (permalink)
mayayana


 
 

Re: Simple? How to copy WWW picture to C drive

> Do you know a way to resize the image after (or while) saving the file
Quote:

> to the local PC?
>
How do you expect you could resize it while saving it?
You'd have to resize it on the server! One option, after
download, would be to use IrfanView command line. There
isn't any basic script functionality to resize an image. It
requires complex calculation to do the job and in the case
of JPG there's another very involved step to resave it as
a JPG file.
Quote:

> When I checked the properties of the image on the web site, the image
> size was about 400x300. When I ran your script it saved the file at
> about 640x400. My goal is to get it down to 300x200 +/-.
> Thanks for the tips so far!!

My System SpecsSystem Spec
Old 10-07-2008   #6 (permalink)
Paul Randall


 
 

Re: Simple? How to copy WWW picture to C drive


"Zoiks" <cavalier_102@xxxxxx> wrote in message
news:6d6d45cb-4635-4ce0-b178-7d688e49caa7@xxxxxx
Quote:

> Cool, thanks Joe it worked very well.
> Part two to the question now
>
> Do you know a way to resize the image after (or while) saving the file
> to the local PC?
>
> When I checked the properties of the image on the web site, the image
> size was about 400x300. When I ran your script it saved the file at
> about 640x400. My goal is to get it down to 300x200 +/-.
> Thanks for the tips so far!!
Joe's script just downloads the file from the server. The HTML code that
displays the image in a web page may be specifying a different display size
than the picture's native size. Note that jpg pictures use lossy
compression (non-lossy jpg compression is available, but not free). If you
resize the picture into another jpg file, this will result in further loss
of detail and an increase in blotchyness, depending on the picture content.
Sometimes it is just better to have the HTML code specify the display size.

-Paul Randall


My System SpecsSystem Spec
Old 10-07-2008   #7 (permalink)
Zoiks


 
 

Re: Simple? How to copy WWW picture to C drive

Thanks May & Paul.

I asked the question because I didn't know if it was possible so I
find your comment "How do you expect you could resize it while saving
it" to be a bit inappropriate, a simple no would've been fine.

Thanks for the tips, I'm aware that the HTML can resize the image,
just curious if there are other ways to free up server CPU.
Thanks again.
My System SpecsSystem Spec
Old 10-07-2008   #8 (permalink)
mayayana


 
 

Re: Simple? How to copy WWW picture to C drive

>
Quote:

> I asked the question because I didn't know if it was possible so I
> find your comment "How do you expect you could resize it while saving
> it" to be a bit inappropriate, a simple no would've been fine.
>
> Thanks for the tips, I'm aware that the HTML can resize the image,
> just curious if there are other ways to free up server CPU.
> Thanks again.
Paul Randall made a good point that resizing a JPG
will result in at least some loss of quality.

As for my "inappropriate comment", I just meant to point
out that you seem to misunderstand the process. A
JPG file holds information about the pixels that make up
the JPG image, which has a specific size. To resize that
requires decompressing the image to a bitmap, applying
mathematical calculations to drop out some of the pixels,
the re-converting (compressing) the bitmap to a JPG.
It can't be done easily and it can't be done with HTML.
When you see a resized image in the browser window,
the browser itself has resized the actual image internally,
but that has nothing to do with the file itself. You are
downloading a 640x400 file, no matter what size the
browser shows it as.


My System SpecsSystem Spec
Old 10-09-2008   #9 (permalink)
mr_unreliable


 
 

as far as resizing...

Zoiks wrote:
Quote:

> Do you know a way to resize the image after (or while) saving the file
> to the local PC?
>
As far as resizing, how about that old utility, msPaint?

Yes, it's not very sophisticated, there is no ole object,
but still it will respond to appactivate and sendkeys.

You can open your jpg in mspaint by just using shell.run
with mspaint and the filespec as the parameter.

Then send ctrl-W to get the stretch-and-skew dialog.
Send alt-H to the dialog, and then send the horizontal
percent to expand-or-shrink. Then send alt-V and the
vertical percent to expand/shrink. Send a cr to close
the dialog, and some other keystrokes to save the result.

Caution: you may be tempted to send ctrl-E to get the
attributes dialog, and then enter the horizontal and
vertical dimensions. However, that will "crop" the
image, rather than expand/shrink it.

I apologize if ms has removed msPaint from more modern
systems. However, if msPaint HAS been removed, I suspect
that ms will have offered a more modern replacement,
which (according to ms's programmings standards) ought
to be programmable without the mouse, using the kbd.
Even on a ca 1998 win98 system, you can find a "suite"
of kodak utilities which can be used to edit graphic
images. Also, I purchased a copy of Micrografx Toolkit
at a "firesale" price, which contains "Micrografx Picture
Publisher". While MPP is not adobe, but still does
everything I want to do with it.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
My System SpecsSystem Spec
Old 10-09-2008   #10 (permalink)
mayayana


 
 

Re: as far as resizing...

> As far as resizing, how about that old utility, msPaint?
Quote:

>
You must have a souped-up version of Paint.
Mine will only open bitmaps.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
simple file copy problem VB Script
To copy picture from your profile Live Messenger
How can I copy my picture that I created from WeeMee to My Picture Live Messenger
Can't simple copy from a Mac to my ext HD General Discussion
copy of picture Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46