Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

PC SAS - Reading jpeg images.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PC Guides & IT News
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1458
Location: Azeroth

PostPosted: Fri Jun 24, 2011 5:36 pm    Post subject: PC SAS - Reading jpeg images.
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: 7931
Location: Bellevue, IA

PostPosted: Fri Jun 24, 2011 5:55 pm    Post subject:
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: 1458
Location: Azeroth

PostPosted: Mon Jun 27, 2011 4:34 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Tue Jun 28, 2011 12:15 pm    Post subject:
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: 1458
Location: Azeroth

PostPosted: Tue Jun 28, 2011 1:22 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PC Guides & IT News All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Reading data from PS file and send it... rajatbagga All Other Mainframe Topics 18 Fri Sep 23, 2016 12:51 pm
No new posts Reading selected volumes of a multi-v... RickBig JCL & VSAM 6 Wed Jul 13, 2016 7:26 pm
No new posts Reading from File 1 and Writing to Fi... shiitiizz CLIST & REXX 2 Thu May 14, 2015 5:49 pm
No new posts reading adabas file without descriptor Ralph Zbrog Java & MQSeries 1 Wed Feb 25, 2015 3:28 pm
No new posts Using DSECT - for file reading Apurva Mehta PL/I & Assembler 2 Mon Nov 17, 2014 10:09 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us