BookmarkSubscribeRSS Feed
BenConner
Pyrite | Level 9

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

9 REPLIES 9
ballardw
Super User

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.

Jay54
Meteorite | Level 14

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

 

BenConner
Pyrite | Level 9

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

 


test.png
BenConner
Pyrite | Level 9

Oh..am on 9.4 TS1M3.  Sorry.

 

---Ben

ballardw
Super User

@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.

BenConner
Pyrite | Level 9

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

 

--Ben

BenConner
Pyrite | Level 9
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
BenConner
Pyrite | Level 9
Hm. Updating the test image didn't work either. Will continue to investigate it. --Ben
BenConner
Pyrite | Level 9

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1974 views
  • 0 likes
  • 3 in conversation