powered by
Fill an area with a magick image
fill_area_with_img( img, width, height, type = "squish", gravity = "Center", filter = "lanczos", scale = 1 )
magick image
target dimensions for final image
how to resize the image. 'none', 'fit', 'squish', 'expand' or 'tile'. default: squish
how to anchor the image during the operation. See magick::gravity_types()
magick::gravity_types()
default: lanczos
scale the source image before tiling. default: 1
magick image of the required dimensions
Support fill types
fit - Fill image canvas, preserving aspect, such that one of target width or height is achieved without distoring or cropping.
fit
squish - Fill image canvas, ignoring aspect, such that both the target width and height is achieved.
squish
expand - Fill image canvas, by scaling image and preserving aspect, such that when cropped, the target width and height is achieved.
expand
none - Fill image canvas canvas to the target width/height, and use gravity to place the undistorted image
none
tile - Tile the image canvas with image.
tile
# NOT RUN { filename <- system.file("img", "Rlogo.png", package="png") img <- magick::image_read(filename) fill_area_with_img(img, 100, 400, type = 'squish') # }
Run the code above in your browser using DataLab