R:tiff() 不会压缩或设置分辨率为 300 ppi [英] R: tiff( ) won't compress or set resolution to 300 ppi

查看:106
本文介绍了R:tiff() 不会压缩或设置分辨率为 300 ppi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 R 保存一些图表以供发布.我想用 lzw 压缩它们并将分辨率设为 300.出于某种原因,它不允许我这样做.事实上,似乎 R 忽略了我设置的一些变量.

I am trying to save some graphs using R for publication. I want to have them compressed with lzw and have the resolution at 300. For some reason it won't allow me to do this. In fact, it seems like R is ignoring some of the variables I set.

对于代码示例,

tiff(file="file.tiff", 
            width=6.83, height=6.83, units="in", 
            pointsize="12", compression = "lzw", 
            bg="white", res=300, antialias = "none" )

输出大小为 28 x 28 英寸、分辨率为 72 ppi 的未压缩文件.

outputs an uncompressed file of size 28 x 28 inches and a resolution of 72 ppi.

一个可重复的例子是

hist(rnorm(1000))
dev.off()

这里是 file.tiff 的 ImageMagick 输出

Here is the output of ImageMagick for file.tiff

Image: file.tiff
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 2049x2049+0+0
  Units: PixelsPerInch
  Type: PaletteAlpha
  Base type: TrueColor
  Endianess: MSB
  Colorspace: sRGB
  ...
  Compression: None
  ...
  Filesize: 16.8MB

我在另一个运行 10.7 的 Apple 上对此进行了测试,并得到了相同的结果.可以看出,即使使用选项压缩并将分辨率设置为 300 dpi,输出也不会遵循选项.

I tested this on another Apple running 10.7 and get the same results. As can be seen, even when using the options to compress and set the resolution at 300 dpi, the output does not follow the options.

推荐答案

我通过附加在 GNU/Linux 上使用 R 2.15.1 验证了您的示例

I verified your example with R 2.15.1 on GNU/Linux by appending

hist(rnorm(1000))
dev.off()

到您的 tiff() 调用并使用 /identify.php" rel="nofollow">ImageMagick 的命令行工具 identify(大部分输出省略):

to your tiff() call and checked the resulting file "file.tiff" with ImageMagick's command line tool identify (most output omitted):

Image: file.tiff
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 2049x2049+0+0
  Resolution: 300x300
  Print size: 6.83x6.83
[...]
  Compression: LZW
[...]
  Filesize: 70KB
[...]

R 命令似乎完全符合您的意图.我怀疑您创建 TIFF 文件的方式与您描述的方式不同,或者您用来检查 TIFF 文件属性的工具有问题.

The R command seems to do exactly what you intend to do. I suspect that either you create the TIFF file not in the manner you describe or the tool you use to check the TIFF file's properties is faulty.

这篇关于R:tiff() 不会压缩或设置分辨率为 300 ppi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆