/* Richard A. DeVenezia * www.devenezia.com * * Create a custom TIFF graphics device that will * create images at the dots-per-inch (dpi) resolution * you specify * * Based on content originally posted to SAS-L on August 8, 2003. */ /*----- * group: Data presentation * purpose: Create a TIFF graphics device that outputs images at a custom dpi */ %macro tiffdevice(dpi=300, xmax=10, ymax=10, libnum=0); %local lib cat; %let lib = GDEVICE&libnum; %if 0 ^= %sysfunc(libref(&lib)) %then %do; %put ERROR: &lib has not been assigned; %goto EndMacro; %end; %if %sysfunc (cexist(&lib..devices.tiff&dpi..dev)) %then %do; %put WARNING: &lib..DEVICES.TIFF&dpi already exists, doing nothing; %goto EndMacro; %end; proc gdevice cat=&lib..devices nofs; copy TIFFP from = sashelp.devices newname = TIFF&dpi ; modify TIFF&dpi xmax = &xmax in ymax = &ymax in xpixels = %eval(&xmax * &dpi) ypixels = %eval(&ymax * &dpi) ; quit; %EndMacro: %mend; /**html *

Sample code

*/ goptions reset=all; options mprint noxwait xmin; %let work = %sysfunc(pathname(WORK)); x "mkdir &work.\gdevice0"; x "mkdir &work.\gdevice1"; libname gdevice0 "&work./gdevice0"; libname gdevice1 "&work./gdevice1"; %tiffdevice (dpi=100) %tiffdevice (dpi=150) %tiffdevice (dpi=200, libnum=1) %tiffdevice (dpi=250, libnum=1) %tiffdevice ; data xy; do x = 1 to 10; y = x**2; output; end; run; %macro plot (dpi=); title "&dpi dpi output"; footnote j=r "www.devenezia.com "; goptions target=TIFF&dpi device=TIFF&dpi gsfname=tiffout hsize=1in vsize=1in ftext='Arial' htext=5pct goutmode=replace gsfmode=replace ; filename tiffout "&work.\&dpi..tif"; proc gplot data = xy; plot y * x / name="_&dpi.dpi"; run; quit; title; footnote; %mend; ods listing; %plot(dpi=100) %plot(dpi=150) %plot(dpi=200) %plot(dpi=250) %plot(dpi=300) ods listing close; data _null_; file "&work.\tiffs.html"; put '' / '' / 'Various TIFF resolutions' / '' / '' / '' / '

When a TIFF is rendered by a printer, the images will be the same dimension (1x1in), however the ' / 'higher resolution TIFF will look better


' / '' / '' / '' / '' / '' / '' ; run; goptions reset=all; x "&work.\tiffs.html"; /**html

These images should all be the same size. However, the browsers TIFF plug-in renders the image pixels on the screen at an effective resolution of 95dpi (perhaps because they speculated people would only be viewing TIFF images created at 95dpi) Thus the higher resolution images appear larger when rendered on the screen (because they have more pixels)

dpiimage size
(inches)
pixels
1001 x 1100 x 100
1501 x 1150 x 150
2001 x 1200 x 200
2501 x 1250 x 250
3001 x 1300 x 300

When a TIFF is rendered by a printer, the images should have same dimension (1x1in), however the higher resolution TIFF will look better


*/