使用 R 中的 imageMagick 将白色矩形添加到图像底部
Add white rectangle to bottom of image with imageMagick in R
我希望使用 R 的 magick
库将白色矩形添加到 .png 图像的底部。
白色矩形的尺寸
宽度:1200px
高度:50px
我认为 append 会很有用。但是,我不清楚如何 创建 而不是读取白色矩形图像。具体来说,如何在这张汽车图像的底部添加一个白色矩形,高度为 50px,长度为图像的长度。
library("magick")
url <- "https://images.unsplash.com/photo-1604397707219-dfe825b8a59d"
使用image_blank
创建白色矩形。然后使用 image_composite
.
组合图像
library(magick)
url <- "https://images.unsplash.com/photo-1604397707219-dfe825b8a59d"
img <- image_read(url)
white <- image_blank(1200, 50, "white")
x <- image_info(img)$width - 1200
y <- image_info(img)$height - 50
image_composite(img, white, offset = paste0("+", x, "+", y))
我希望使用 R 的 magick
库将白色矩形添加到 .png 图像的底部。
白色矩形的尺寸
宽度:1200px
高度:50px
我认为 append 会很有用。但是,我不清楚如何 创建 而不是读取白色矩形图像。具体来说,如何在这张汽车图像的底部添加一个白色矩形,高度为 50px,长度为图像的长度。
library("magick")
url <- "https://images.unsplash.com/photo-1604397707219-dfe825b8a59d"
使用image_blank
创建白色矩形。然后使用 image_composite
.
library(magick)
url <- "https://images.unsplash.com/photo-1604397707219-dfe825b8a59d"
img <- image_read(url)
white <- image_blank(1200, 50, "white")
x <- image_info(img)$width - 1200
y <- image_info(img)$height - 50
image_composite(img, white, offset = paste0("+", x, "+", y))