BookmarkSubscribeRSS Feed
ucvikas
Obsidian | Level 7

Hi

I have some images and I want to to crop those images so that I can use them to place on the same page . Reason to crop the image is to maintain the quality of the desired image so that I do not loose valuable space on the page while placing them on same page in PDF file .

Original image is produced by PROC GKPI in HTML file then using PROC GSLIDE it is saved as png image then using PROC GREPLAY images are placed on the same page of the pdf .

I had to to follow above complex steps to combine four graphs produced by PROC GKPI as It seems that PROC GKPI does not produce images in catalog..

Has anyone solution or alternate way of doing the task ???

10 REPLIES 10
GraphGuy
Meteorite | Level 14

Let me re-state your question, just to make sure I understand what you're wanting...

You want a programmatical way (in SAS) to get rid of the white-space around the Proc Gkpi gauges/etc output images, so that you can then annotate/greplay them tightly onto the same page without overlapping?

Or, if someone has an alternate way to create such a Gkpi dashboard, you'd also be receptive to that.

ucvikas
Obsidian | Level 7

Yes . Exactly .

GraphGuy
Meteorite | Level 14

With the absence of any answers/suggestions, I think this might not be do-able.

This might be a good thing to contact tech support about, and ask them to enter a request for adding functionality to Proc GKPI to allow the user to better control the white-space around them.

ucvikas
Obsidian | Level 7

Yeh .. This may be good idea for future version of SAS but as a soulution I also do not see any better way out of it . Anyway I never knew that we can request SAS Support for improvements in existing PROCs (don't know whether it counts or not); but yes PROC GKPI despite being execellent procedure has little to offer me regarding control on graphs. Smiley Happy

drimage
Calcite | Level 5

i am looking forward to the solution of image cropping c# idea, i found it is hard to get rid of the white space. the quality of images is important .

GraphGuy
Meteorite | Level 14

OK - I might have figured out a programmatical (in SAS) work-around for you ...

Rather than annotating the gkpi image into a gslide within the xsys/ysys=3 0-100 coordinates, you can actually annotate the image *outside* of the visible 0-100 coordinates, thereby chopping (cropping) off the edges. ... Or, as I like to call it, literally "thinking outside the box" Smiley Happy

Here is an example where I chop off some of the left & right edges of a gkpi png, to get rid of some of the white space:

data anno_img;
length function $8;
xsys='3'; ysys='3';
x=-15; y=0; function='move'; output;
x=115; y=100; function='image'; imgpath='gkpi4.png'; style='fit'; output;
run;

goptions xpixels=300 ypixels=300;
proc gslide anno=anno_img;
run;

I'm attaching the gkpi4.png image (that I used in the example code), if you want to use that to experiment with:

gkpi4.png

Jay54
Meteorite | Level 14

What sort of KPI are you using?

WDZ
Calcite | Level 5 WDZ
Calcite | Level 5

I've been messing around with this, since I have a similar problem with the white spaces...

What solved it for me was just setting the "correct" goptions.

The line that worked for me came from this presentation: http://www.sas.com/offices/NA/canada/downloads/presentations/TASS09/PROC-GKPI.pdf.

It was: goptions reset=all rotate=landscape device=javaimg xpixels=240 ypixels=200;

This created a compact image without all the white space in my html file. If you change the pixels, it sometimes messes it up again (e.g. xpixels=480 ypixels=400 didn't work for me, but xpixels=320 ypixels=240 did work). I'm assuming the landscape view also has to do with this (i.e. I think SAS autofits the image in some strange way and you need to trick it into doing it in a nicer way).

Hope this helps!Smiley Happy

gfjump
Calcite | Level 5

never try to crop image with this kind of code before. i hope i can get the best size image. image cropping is useful but can i resize image with this code.

arronlee
Calcite | Level 5

Hi, gfimage.

Thanks for your nice sharing. Here are some code about the related image resizing process:

Imports System.Drawing

Imports System.Drawing.Imaging

Imports PQScan.PDFToImage

Namespace SpecifyImageSize

  Class Program

   Private Shared Sub Main(args As String())

   ' Create an instance of PQScan.PDFToImage.PDFDocument object.

   Dim pdfDoc As New PDFDocument()

   ' Load PDF document.

  pdfDoc.LoadPDF("sample.pdf")

   ' Set dpi to render image

  pdfDoc.DPI = 96

   'Get total page count.

   Dim count As Integer = pdfDoc.PageCount

   For i As Integer = 0 To count - 1

   'Convert page to image in target size

   Dim bmp As Bitmap = pdfDoc.ToImage(i, 100, 200)

   'Save image

  bmp.Save("output" & i & ".jpg", ImageFormat.Jpeg)

   Next

   End Sub

  End Class

But I wonder how can I accomplish the image resizing process. Do I need another image resizing SDK to help customize the size of images? I am almost a green hand here. Any suggestion will be appreciated. Thanks in advance.   

Best regards,

Arron

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 10 replies
  • 2587 views
  • 0 likes
  • 7 in conversation