| render_crop | R Documentation |
Crops an image (or matrix) either by specifying axis-aligned limits
(width_limits/height_limits) or by specifying a centered box size via center.
render_crop(
image = NULL,
width_limits = NULL,
height_limits = NULL,
center = NULL,
filename = NULL,
preview = FALSE
)
image |
Default |
width_limits |
Default |
height_limits |
Default |
center |
Default |
filename |
Default |
preview |
Default |
A rayimg array with the cropped region.
# Left half of the image
render_crop(dragon,
width_limits = c(0, 0.50),
height_limits = c(0, 1)) |>
plot_image()
# Right half of the image
render_crop(dragon,
width_limits = c(0.50, 1),
height_limits = c(0, 1)) |>
plot_image()
# Top middle of the image (25%–50% height, 25%–75% width)
render_crop(dragon,
height_limits = c(0.25, 0.50),
width_limits = c(0.25, 0.75)) |>
plot_image()
# Top middle, explicit pixel coords (for a 200x200 image)
render_crop(dragon,
height_limits = c(50, 100),
width_limits = c(50, 150)) |>
plot_image()
# Center-crop: 50% height and width of the image
render_crop(dragon, center = c(0.5, 0.5)) |>
plot_image()
# Center-crop: fixed 50x100 pixels
render_crop(dragon, center = c(50, 100)) |>
plot_image()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.