I have 2 png map images. I would like to put one in the corner of the other. Is there any way to do this using R Markdown? I have previously created the images using leaflet.
Hi @Jonw!
I realize I may sound like a broken record here , but I think
magick
is definitely the ticket for this job:
---
title: "Picture-in-Picture!"
output: html_document
---
```{css, echo=FALSE}
body {background-color: #777; color: #fff;}
```
```{r}
library(magick)
img <- image_read("https://i.imgur.com/esbT74s.png")
img_inset <- image_scale(img, "30%x") %>%
image_border("white", "5x5")
img_with_inset <- img %>% image_composite(
img_inset,
operator = "Atop",
gravity = "SouthWest",
offset = "-10-10"
)
image_write(img_with_inset, "img_with_inset.png")
```
# A rose in a rose
```{r}
knitr::include_graphics("img_with_inset.png")
```
1 Like
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.