IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

PC SAS - Reading jpeg images.


IBM Mainframe Forums -> PC Guides & IT News
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Jun 24, 2011 5:36 pm
Reply with quote

Hello,
I am trying to have a jpeg image as input and then write it to output. But unable to do so.
Tried the below code,

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 end=eof;
input;
file 'c:\image.jpg';
put _infile_;
run;


The output file c:\image.jpg was a 4KB file & unable to open it, where as the original image was around 25 KB.
Please let me know your thoughts on reading a image fle.

Thanks,
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 24, 2011 5:55 pm
Reply with quote

A quick check of the SAS site seems to indicate you need SAS/ACCESS to properly handle image files. I've never had a need to manipulate one, so I don't know if this is true or not.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Mon Jun 27, 2011 4:34 pm
Reply with quote

Hello Robert, Thanks for your thought.
I have had some progress/luck with the requirement..

1) I was able to successfully read the HTML code of a website using,
Code:
Filename www url 'www.yahoo.com';
data _null_;
infile www url end=eof;
input;
file 'c:\html.txt';
put _infile_;
run;

So I guess SAS/ACCESS or SAS/Connect is working.

2) Was able to successfully read an image stored locally and then store it locally in another place,
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;


But when both 1) & 2) are combined,
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..
back to square 1 :S

Thanks,
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Jun 28, 2011 12:15 pm
Reply with quote

As far as i understand you cant use the HTTP protocol to read binary files.
Maybe you could use the FTP protocol.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Jun 28, 2011 1:22 pm
Reply with quote

Hi Peter, Thanks for viewing & your thoughts.

I was able to get a solution to the problem from Listserv SAS group. The below codes work in getting a image from internet & store it on PC.

Adding the right RECFM did the trick.
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' RECFM=S;
data _null_;
infile www;
input;
file 'c:\temp\junk.jpeg' RECFM=F;
put _infile_;
run;


or

Code:
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;


Thanks,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PC Guides & IT News

 


Similar Topics
Topic Forum Replies
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Rexx program reading a DSN then write... CLIST & REXX 4
No new posts Reading subsequent rows in a query. DB2 12
No new posts COBOL reading from SYSIN COBOL Programming 1
Search our Forums:

Back to Top