如何在R中使用magick保存高分辨率图像? [英] How to save a high resolution image with magick in R?

查看:155
本文介绍了如何在R中使用magick保存高分辨率图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 magick 包创建3 x 3的高分辨率蒙太奇".

I would like to create a high resolution "montage" of 3 by 3 using the magick package.

library(magick)
#> Linking to ImageMagick 6.9.7.4
#> Enabled features: fontconfig, freetype, fftw, lcms, pango, x11
#> Disabled features: cairo, ghostscript, rsvg, webp

# Read the image and resize it
frink <- image_read("https://jeroen.github.io/images/frink.png")
frink <- image_resize(frink, "100x")

# Create 1 column with 3 rows
col <- image_append(rep(frink, 3), stack = TRUE)

# "Combine" 3 columns
i <- image_append(c(col, col, col))

i

所以我的问题是如何将其保存为高分辨率png(例如300 DPI)?我当时在考虑使用 image_write(),但显然我无法在此处设置所需的分辨率.

So my question is how can I save it to a high-resolution png (e.g., 300 DPI)? I was thinking to use image_write(), but apparently I can not set the resolution I want there.

# This is not working
# image_write(i, tempfile(), res = 300)

谢谢你,菲尔

reprex软件包(v0.2.1)创建于2019-05-09 sup>

Created on 2019-05-09 by the reprex package (v0.2.1)

推荐答案

我遇到了同样的问题,但是在magick vignett中找到了解决方法 https://docs.ropensci.org/magick/articles/intro.html#read-and-write

I had the same problem but found the solution in the magick vignett https://docs.ropensci.org/magick/articles/intro.html#read-and-write

image_write(i, path = "final.png", format = "png")

这篇关于如何在R中使用magick保存高分辨率图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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