The aim is to
- convert any input image to square aspect ratio and
- add a circular mask and fill the outside with white or transparency.
I have got 1 to work, but not sure it's the best way to do it. Here is a working example.
library(magick)
path <- "https://cdn.pixabay.com/photo/2016/08/17/21/12/people-1601516_960_720.jpg"
img <- magick::image_read(path)
img
Original image
ii <- magick::image_info(img)
ii_min <- min(ii$width,ii$height)
img1 <- magick::image_crop(img, geometry=paste0(ii_min,"x",ii_min,"+0+0"),repage=TRUE)
img1
Cropped Square Aspect Ratio
I am not sure how to get the last part (2) to work in R. Although I have sort of managed to get it to work using image-magick in unix.
convert -size 500x500 xc:white -fill cropped.jpeg -draw "circle 250,250 250,1" circ.jpg
Circular Frame
I am looking for a solution to 2 in R.



