Learn R Programming

ggpattern (version 0.1.3)

fill_area_with_img: Fill an area with a magick image

Description

Fill an area with a magick image

Usage

fill_area_with_img(
  img,
  width,
  height,
  type = "squish",
  gravity = "Center",
  filter = "lanczos",
  scale = 1
)

Arguments

img

magick image

width, height

target dimensions for final image

type

how to resize the image. 'none', 'fit', 'squish', 'expand' or 'tile'. default: squish

gravity

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

filter

default: lanczos

scale

scale the source image before tiling. default: 1

Value

magick image of the required dimensions

Details

Support fill types

  • fit - Fill image canvas, preserving aspect, such that one of target width or height is achieved without distoring or cropping.

  • squish - Fill image canvas, ignoring aspect, such that both the target width and height is achieved.

  • expand - Fill image canvas, by scaling image and preserving aspect, such that when cropped, the target width and height is achieved.

  • none - Fill image canvas canvas to the target width/height, and use gravity to place the undistorted image

  • tile - Tile the image canvas with image.

Examples

Run this code
# 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