Date: Mon, 27 Jun 2011 14:27:27 -0400
Reply-To: Arthur Tabachneck <art297@ROGERS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@ROGERS.COM>
Subject: Re: PC SAS - Reading jpeg images.
Vansanth,
I was waiting to see if someone else offered a better solution but, as they
haven't, the following should work:
filename in url
'http://europe.nokia.com/PRODUCT_METADATA_0/Products/Phones/N-series/N9-
00/images/nokia_n9-00_black_main-overview.jpg';
filename out "c:\picture845.jpg";
/* copy the file byte-for-byte */
data _null_;
length filein 8 fileid 8;
filein = fopen('in','I',1,'B');
fileid = fopen('out','O',1,'B');
rec = '20'x;
do while(fread(filein)=0);
rc = fget(filein,rec,1);
rc = fput(fileid, rec);
rc =fwrite(fileid);
end;
rc = fclose(filein);
rc = fclose(fileid);
run;
filename in clear;
filename out clear;
HTH,
Art
------
On Mon, 27 Jun 2011 16:51:57 +0530, vasanth s <vasanthz@GMAIL.COM> wrote:
>Hello All,
>I am trying to have a jpeg image from WWW as input and then store it in my
>PC. But unable to do so.
>Tried the below code,
>
>filename www url '
>http://europe.nokia.com/PRODUCT_METADATA_0/Products/Phones/N-series/N9-
00/images/nokia_n9-00_black_main-overview.jpg';
>
>data _null_;
>infile www url recfm=n;
>length byte $1;
>input byte $char1.;
>file 'c:\picture845.jpg' recfm=n;
>put byte $char1. @;
>run;
>
>The output file c:\picture845.jpg was a 4KB file & unable to open it..
>Whereas the original file on the WWW was 25KB.
>
>Some other attempts that I have made to approach the above requirement are,
>*-> reading HTML data from a website & the code works fine,*
>Filename www url 'www.yahoo.com';
>data _null_;
>infile www url end=eof;
>input;
>file 'c:\html.txt';
>put _infile_;
>run;
>
>*-> **Was able to successfully read an image stored locally and then store
>it locally in another place, using below code*
>filename picture 'C:\Documents and Settings\All Users\Documents\My
>Pictures\Sample Pictures\sunset.jpg';
>data _null_;
>infile picture recfm=n;
>length byte $1;
>input byte $char1.;
>file 'c:\picture.jpg' recfm=n;
>put byte $char1. @;
>run;
>
>Please let me know your thoughts on how to save a picture on the internet
>into local computer.
>
>Thanks for viewing,
>Vasanth.S
|