Learn R Programming

ggpattern (version 0.1.3)

fill_area_with_img_fit: Resize image, preserving aspect, such that one of target width or height is achieved without distoring or cropping.

Description

The canvas of the image will be expanded to cover the full width/height but will be transparent.

Usage

fill_area_with_img_fit(
  img,
  width,
  height,
  gravity = "Center",
  filter = "lanczos"
)

Arguments

img

magick image

width

target dimensions for final image

height

target dimensions for final image

gravity

how to anchor the image during the operation. See magick::gravity_types()

filter

default: lanczos

Value

magick image of the required dimensions

Examples

Run this code
# NOT RUN {
filename <- system.file("img", "Rlogo.png", package="png")
img <- magick::image_read(filename)
fill_area_with_img_fit(img, 100, 400)
# }

Run the code above in your browser using DataLab