BookmarkSubscribeRSS Feed
scan
Obsidian | Level 7

Dear All,

is it possible to split a single png image into two different png files with SAS?

 

Let's say dividing a file IMAGE.png into the upper 80% portion of the image and the 20% on the bottom, saving them as TOP.png and BOTTOM.png, keeping the same resolution?

 

Many thanks, any hint appreciated,

Scan

12 REPLIES 12
Kurt_Bremser
Super User

SAS is really not an image manipulation utility. I'd suggest dedicated software like IrfanView, Potoshop or gimp for this.

gimp should have something that can be used from the commandline.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, yes, it is possible.  Depends if you have 6 months or so to write a parser for the filetype.  File format is given here:

https://en.wikipedia.org/wiki/Portable_Network_Graphics

 

Nothing stopping you form reading in the binary data, manipulating as you want, then writing out. 

 

Is this a good idea, no.  Why are you attempting to use a picture?  Go back to the srouce data, and regenerate the output with the part you want.  Alternatively use a paint app as @Kurt_Bremser has said, however I personally see that as not being a good idea either, the whole picture would be there for a reason, chopping out a certain bit of it just removes most of the consolidating reference data.  Take for example a graph, the axis is there so the points have reference, you could chop out a bit, but does it still convey anything.

scan
Obsidian | Level 7

Thank you all,

 

I need to do it in SAS and no, unfortunately I don't have 6 months.

 

Any workaround? As an example I think that probably it is possible trying to fit it in a smaller box, basically cutting the bottom side of the image. But what about the upper side?

 

 

Kurt_Bremser
Super User

Let's repeat: SAS does NOT have built-in image manipulation tools. Period. To manipulate an existing image, you would have to write that byte-by-byte yourself. Use a proper tool (easily available for all platforms, as mentioned) to do this.

ChrisHemedinger
Community Manager

As @Kurt_Bremser and @RW9 have said, it's probably better to examine what you need for these images and try to build the graphs natively in SAS based on your data, rather than post-process the image.


SGPLOT supports a "broken axis" that might help you to segment your report.  Otherwise, you might be able to build what you need in GTL.  You can start with the ODS Graphics Designer to build a layout with your data, which will generate the code that you can then process with PROC SGRENDER.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Rick_SAS
SAS Super FREQ

Please post your image so we can see what is in it. Also post the version of SAS that you are using.

We can then suggest ways to produce output that might meet your business objectives. 

scan
Obsidian | Level 7

Thanks for the interest.

 

Basically I have a KM graph with patients at risk at the bottom.

This is produced with a layout lattice with united datarange in order to align the two elements.

I want to produce 2 different png mantaining the alignment.

 

I solved for the moment creating 2 different png files with the same templating simply changing the vertical dimension of the graph and assigning the row dimension to (0.99 0.01) to the km graph and (0.01 0.99) to the second element with pt at risk.

I still have the labels of the second element creating a black box on the left bottom of the km graph, solved it whitening the text.

 

This is very dirty but works.

If you have better hints on how to proceed I will be glad to accept them.

 

Is there a way to delete the space between the border of the graph (max y-axis) and the border of the image (on the top)?

Because I'm actually having a lot of space between the first and second element. 

I tried to define a style with 

 


proc template;
define style NEWSTYLE;
parent = styles.listing ; 
replace Body from Document /
 bottommargin = 0 cm
 topmargin = 0 cm
 rightmargin = 0 cm
 leftmargin = 0 cm
 ;
 replace Body from Output /
 bottommargin = 0 cm
 topmargin = 0 cm
 rightmargin = 0 cm
 leftmargin = 0 cm
 ;
end;
run;

but it does not work.

 

I'm running on 9.4.

 

Many thanks,

Scan

Rick_SAS
SAS Super FREQ

Let's repeat one more time. If you would like help, please post

  1. Your image so we can see what is in it.
  2. The version of SAS that you are using.
  3. The SAS syntax and sample data would be especially welcome, especially if the data is from a SASHelp data set or from the documentation.
scan
Obsidian | Level 7

Thank you Rick,

probably tomorrow I'll be free to adapt the code to a sashelp dataset.

As you know I can't post code/datasets before making it completely generalised.

Many thanks for the help so far, not only today.

I'll return here with the requested things.

ballardw
Super User

Instructions at https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... turn a dataset into data step code.

 

It shouldn't be hard to obfuscate a few variables to demonstrate what you are doing.

rogerjdeangelis
Barite | Level 11

Do you have the IML interface to R?  Can you call Python?

ChrisNZ
Tourmaline | Level 20

If you create your plots with SAS/GRAPH (proc gplot rather than proc sgplot), you can use proc greplay to put them back together as one plot, positioning them as you like, including overlapping to hide parts of some graphs.

 

As far as I know, the SG procedures cannot output to catalog, and there is no proc sgreplay.

 

 

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
  • 12 replies
  • 1402 views
  • 4 likes
  • 8 in conversation