library(magick)
str(magick::magick_config())

#Potong dan Edit

Example image

frink <- image_read("https://jeroen.github.io/images/frink.png")
print(frink)
# Add 20px left/right and 10px top/bottom
image_border(image_background(frink, "grey"), "#000080", "20x10")

Trim margins

image_trim(frink)

Passport pica

image_crop(frink, "50x50+90")

Rotate or mirror

image_rotate(frink, 105)

Brightness, Saturation, Hue

image_modulate(frink, brightness = 80, saturation = 120, hue = 90)

Paint the shirt grey

image_fill(frink, "grey", point = "+100+200", fuzz = 20)

Add randomness

image_blur(frink, 10, 5)
image_negate(frink)
image_oilpaint(frink)

##Kernel convolution

kern <- matrix(0, ncol = 3, nrow = 3)
kern[1, 2] <- 0.25
kern[2, c(1, 3)] <- 0.25
kern[3, 2] <- 0.25
kern
img <- image_resize(logo, "300x300")
img_blurred <- image_convolve(img, kern)
image_append(c(img, img_blurred))

Add some text

image_annotate(frink, "HEI YOU!", size = 70, gravity = "southwest", color = "black")

Fonts may require ImageMagick has fontconfig

image_annotate(frink, "STOP!!", font = 'Times', size = 60)

#IMAGE VECTORS

Download earth gif and make it a bit smaller for vignette

earth <- image_read("https://jeroen.github.io/images/earth.gif") |>
  image_scale("200x") |>
  image_quantize(128)

length(earth)
earth