collage
collage copied to clipboard
collage multiple png into a single image of higher device size
Hi got this issues when trying to install the package. Can you please let m know if this is compatible with R4.02.
I don't think this is on CRAN, so you need to do remotes::install_github("ThinkR-open/collage")
Thank you. I am trying to collage multiple png into a single png of higher size than my default device size. SO question here. I came across this package. Wondering if this is the right package for what I am trying to achieve?
Have a look at the image_montage
function in the magick package.
example.zip update: added an example images.
image_files <-
list.files(
path = here::here("example"),
recursive = TRUE,
pattern = "\\.png$",
full.names = TRUE
)
files <- image_files
img <- magick::image_read(files) %>%
magick::image_montage(tile = '2',geometry = 'x500+10+10') %>%
magick::image_convert("jpg") %>%
magick::image_write(format = ".jpg", path = here::here("test.jpg"),
quality = 100)
figured from the documentation that geometry parameter controls the width and height. and the tile controls the column.
# A tibble: 1 x 7
format width height colorspace matte filesize density
<chr> <int> <int> <chr> <lgl> <int> <chr>
1 "" 1290 2080 sRGB FALSE 0 72x72
2 "" 1290 2080 sRGB FALSE 0 72x72
- How to pass arguments for a custom title for the collage image, footer ? Would like to add title, datestamp etc
Can you add example images to your script so I can reproduce your issue?
updated the Q, with an example.zip. Please ignore the image as I just created copies of the same image.
The tile
controls the column and rows, for example 4x3
. See the docs. To overlay text you can use image_annotate()
Thank you jeroen, the documentation was helpful. When using image_annotate, the text is more over laid on top of the image rather than a centered heading with space around it. Is there any better way to include a title, sub-text, footer etc ?
Did you try the location
and gravity
parameters? If you set gravity = "north"
it will be centered at the top.
yes, I am using
magick::image_annotate("The group A charts",
size = 75, location = "+000+000" ) .
Tried the ,gravity = "north", the text is centered but still I see the text is over the y axis
If you want to add space around your figure, you can try image_border()
. Or you can start with image_blank()
to create a canvas and then image_composite()
your image on top of it.
But if you just want to combine plots, have you looked at the patchwork package? https://patchwork.data-imaginist.com/