I am wondering could any of you having a way to detect the dimention sizes (resolution) of an external image file within a SAS session dynamically. I have created as import macro to load image files in JP(E)G, PNG, GIF etc. format, but the original image size is essential to keep the graph aspect ratio in SAS. Many thanks in advance.
However, this is not an ODS or BASE Reporting procedure question and for a question like this, Tech Support is your best bet for help, especially, since doing anything dynamically generally involves using the SAS Macro facility.
To contact Tech Support, go to http://support.sas.com and on the left-hand navigation pane, click on the link, entitled: "Submit a Problem".
Many thanks to your timely reply and advices. The question has sent to SAS support 3-4 months ago, the reply was no method so far can detect external image size from within SAS session. That's why I am trying to have advices or tips from our fellow experts.
I might have not been given the scenario very clear here. In my case, I want to import image files (in GIF, PNG, JP(E)G BMP format, which were created from other Stat application such as S-plus, R, Sigmaplot etc., most possibly done by other people and the size is not known) into SAS, then re-load it into PDF file. So far, the macros of importing and reloading were developed and work well. The problem comes from time to time that, if external image size (in terms of Inch, cm or Pixels) not manaully give to the import macro, the final image in PDF file might be squeezed or streched too much. So far, many of the SAS DOCs were emphasized on exporting the graphs to PDF, HTML etc. as those you have mentioned to me (thanks again), but less in importing. There is one for importing external CGM file but not useful to me.
You say "resolution," that is, pixels per inch or centimeter, but it sounds like you mean "dimensions," the number of columns and rows.
In either case, check out ImageMagick at http://www.imagemagick.org. This package includes a command called "identify" that prints the dimensions and resolution of an image along with a lot of other information. Here's a SAS program that runs identify and parses its output:
filename id pipe 'identify myimage.jpg';
attrib imgname length=$12 format length=$8 dimensions length=$9;
Skip to the 2nd line. The first word in the line is the image filename.
The 2nd is the image format, in this case 'JPEG'. The third word are the
dimensions, which are displayed in the form CCCCxRRRR.
input / imgname format dimensions;
columns = input(scan(dimensions, 1, 'x'), best.);
rows = input(scan(dimensions, 2, 'x'), best.);
If you need the resolution use the -verbose option on identify.
ImageMagick is free, supports over 100 different image formats, and runs on just about any platform you can imagine.
I remember having to do this too many years ago. There was a way to examine the code in the image to determine the height and width of the file. I'm afraid I can't remember the code that I used but I do remember that I started with some rexx code that was first developed for OS/2.
Many thanks to all of your contribution to solve my problem.
With the file "ImageMagick-6.3.7-1-Q16-windows-dll.exe" downloaded from "http://www.imagemagick.org/script/binary-releases.php#windows" and installed on my PC, the SAS program below can directly get image resolution (or size roughly in IN) as wanted.