crop: Cropping functions

cropR Documentation

Cropping functions

Description

Reads in an image and crops to the specified geometry with a transparent background. If a new path is given it will save the cropped images to the new location. If no path is given it will save to a temporary location which will be cleared when the session is closed

Usage

circle_crop(
  images,
  to = NULL,
  border_size = NULL,
  border_colour = "black",
  just = "center"
)

square_crop(
  images,
  to = NULL,
  border_size = NULL,
  border_colour = "black",
  just = "center"
)

hex_crop(
  images,
  to = NULL,
  border_size = NULL,
  border_colour = "black",
  just = "center"
)

heart_crop(
  images,
  to = NULL,
  border_size = NULL,
  border_colour = "black",
  just = "center"
)

Arguments

images

Vector of image paths, either local or urls. If urls the images will be downloaded first.

to

Path to new location

border_size

Border size in pixels.

border_colour

Border colour.

just

Where to justify the image prior to cropping. Accepted values: 'left', 'right', 'top', 'bottom'

Value

Path to cropped images

Examples

library(cropcircles)
library(magick)

img_path <- file.path(system.file(package = "cropcircles"), "images", "walter-jesse.png")
img_cropped <- circle_crop(img_path, border_size = 6)
image_read(img_cropped)

# other geometries

image_read(hex_crop(img_path, border_size = 6))
image_read(heart_crop(img_path, border_size = 6))

# justification example

# center (default)
image_read(circle_crop(img_path, border_size = 6))

# left
image_read(circle_crop(img_path, border_size = 6, just = "left"))

# right
image_read(circle_crop(img_path, border_size = 6, just = "right"))

cropcircles documentation built on May 1, 2023, 1:08 a.m.