The resolution and compression options in tiff()
seem to be ignored on my system (see information below). This appears to be the same problem discussed in this SO question; I'm posting the question here so that I can be more specific about my system.
For instance the following code,
x <- rnorm(1000)
tiff("example.tiff", height=3, width=5, units="in", res=200, compression="lzw")
hist(x)
dev.off()
yields a .tiff file that superficially looks fine, but when I use Photoshop to look at the image size, I see this
This is consistent with tiff()
creating a file with the right number of pixels, but the wrong size in inches. (This discrepancy gets me into trouble when I want to control both the font size and the image size of an image, for instance for publications that require specific physical image sizes).
Note that the file is also 2.5 MB, which seems too big for a 3"-by-5" black-and-white lzw-compressed tiff. I suspect that the compression option is also being ignored.
I get the same result with ggsave
(which might rely on tiff()
under the hood?) and with png()
, so this seems to be a general problem with the way R and OSX deal with image files.
I'm using R Studio 0.97.449, with R 3.0.0 on OSX 10.8 as detailed below.
> sessionInfo()
R version 3.0.0 (2013-04-03)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.0.0