{r setup, include=FALSE} knitr::opts_chunk$set(eval = FALSE)
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
本文于r format(Sys.Date(), "%Y-%m-%d")更新。 如发现问题或者有建议,欢迎提交 Issue
可以对图片进行操作。 [@Ooms2018]
基本功能
{r} library(magick) frink <- image_read("https://jeroen.github.io/images/frink.png") frink image_trim(frink) # 裁剪空白地方 image_scale(frink, "200x200") # resize image_flip(frink) # 旋转 image_rotate(frink, 45) # 旋转 image_rotate(frink, 180) # 旋转 image_negate(frink) frink %>% image_background("green") %>% # 修改背景颜色 image_flatten() %>% image_border("red", "10x10") # 加边框 # image_rotate(frink, 45) %>% # image_write("frink-rotated.png") # 导出图片 image_oilpaint(frink) image_implode(frink) image_charcoal(frink) ## <-- result of this is shown image_blur(frink) image_edge(frink)
pipeline
{r eval=F} library(magick) file.path('../','picbackup') %>% list.files(full.names = T) %>% str_subset('reprex') %>% data.table(x=.) %>% mutate(x = map(x,image_read)) %>% mutate(x = map(x,~image_scale(.,"1000x1000"))) %>% # resize to fit better .$x %>% image_join %>% image_animate(fps=1) %>% image_write( file.path( '../','picbackup' ,'reprex201811061210.gif' ) )
image_join可以转换list为c()格式,让image_animate调用。 github