Data visualization with SAS programming

ODS Graphics problem with transparent background

Reply
Regular Contributor
Posts: 163

ODS Graphics problem with transparent background

Hi,

 

Has anyone successfully brought in an external gif/png image with a transparent background and gotten it to work as expected?

 

I have an ODS LAYOUT region with a colored background, and tried to drop a png image file on to it that has a transparent background.  I want the underneath layer to show through the transparent part.  Target is a PDF file.

 

I'm not sure if it is the .png file or what I'm doing in SAS.

 

Thanks!

 

--Ben

Grand Advisor
Posts: 10,210

Re: ODS Graphics problem with transparent background

It might help to show the code you have that involves the ODS statement and the procedure(s) that reference the PNG file so we have some details to discuss to consider.

Also the version of SAS you are running might be a factor.

SAS Super FREQ
Posts: 1,080

Re: ODS Graphics problem with transparent background

It depends on what procedures you are using for graphics.  Here are many examples using transparent images with SGPLOT procedure:  http://blogs.sas.com/content/graphicallyspeaking/?s=transparent+images

 

Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

I was running a sample program:

dm 'clear log';

ods escapechar='^';
ods PDF file="&path.test.pdf" notoc;

ods layout absolute y=.25in x=.25in  width=10.5in height=8in style={background=green};

ods region width=10in height=7in;
ods text = "^{style[background=blue postimage='&impath.test.png'].}";

ods layout end;

ods pdf close;

 

With the attached test.png; orientation was landscape.  Was expecting the cyan hexagon to have a green background and the surrounding rectangle to be either blue or green.  It was magenta, which was the color I had tried to set to transparent.

 

--Ben

 

Attachment
Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

Oh..am on 9.4 TS1M3.  Sorry.

 

---Ben

Grand Advisor
Posts: 10,210

Re: ODS Graphics problem with transparent background

[ Edited ]

BenConner wrote:

 

With the attached test.png; orientation was landscape.  Was expecting the cyan hexagon to have a green background and the surrounding rectangle to be either blue or green.  It was magenta, which was the color I had tried to set to transparent.

 

 

 


Perhaps the plot thickens: How did you attempt to set the magenta to transparent? Does that image appear transparent when viewing it in other applications or viewers?

 

This link

http://stackoverflow.com/questions/14220221/how-to-insert-transparent-png-in-pdf

may shed some light in general about PNG, transparency and PDF.

Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

Interesting post.  So apparently png files aren't natively compatible with PDF files.  How about gifs?

 

--Ben

Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

Had time to explore other options in the graphics package I used to create the test image with and it told me I had no transparent layer. Oops. I've now created one and will test it. --Ben
Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

Hm. Updating the test image didn't work either. Will continue to investigate it. --Ben
Regular Contributor
Posts: 163

Re: ODS Graphics problem with transparent background

Good morning,

 

It does appear it was an issue with how the transparency layer was defined in the image.  Used a different graphics package that I know better and it worked as advertised.  Including as a .png file.

 

Sorry for the confusion!

 

--Ben

Ask a Question
Discussion stats
  • 9 replies
  • 495 views
  • 0 likes
  • 3 in conversation