[R] JPEG command not responding to size options
Fisher Dennis
fisher at plessthan.com
Fri Apr 24 20:01:26 CEST 2015
R 3.2.0
OS X
Colleagues
I have a script that has been unchanged for years but I just noticed a difference in the output. A minimal example is:
jpeg(file="xxx.jpeg", width=4, height=2, unit="in", pointsize=12, bg="white", res=150, quality=100)
plot(1)
graphics.off()
system("open xxx.jpeg") ## works in OS X -- use 'start' instead of 'open' in Windows
In the past (probably more than several months ago, although I can’t identify when the change occurred), this yielded a graphic that appears to be the intended size (4 x 2). I assess this based on the size on the screen and the size when I drag the file to a Word document.
With R 3.2.0 (and 3.1.3), the image is appreciably larger, i.e., the width and height options appear to be ignored.
OS X’s Preview application includes an inspector that provided information about the images.
In the earlier incarnations, Inspector reported that the image has 150 pixels / inch. With 3.2.0, it shows 72 pixels / inch.
I think that the problem is as follows — the image is created with the correct number of pixels — but the info as to pixels / inch is not being handled correctly.
I can confirm this by replacing
res=150
with
res=72
The resulting image is the intended size.
Is this a bug? The workaround appears to be restoring res=72 but that does not seem to be an ideal solution.
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
More information about the R-help
mailing list