# NOT RUN {
logo <- image_read("https://www.r-project.org/logo/Rlogo.png")
logo <- image_scale(logo, "400")
image_trim(logo)
image_background(logo, "pink", flatten = TRUE)
image_crop(logo, "400x400+200+200")
image_scale(logo, "200x200")
image_sample(logo, "200x200")
image_border(logo, "red", "10x10")
image_despeckle(logo)
image_median(logo)
image_reducenoise(logo)
image_noise(logo)
image_blur(logo, 10, 10)
image_charcoal(logo)
image_edge(logo)
image_oilpaint(logo)
image_emboss(logo)
image_enhance(logo)
image_equalize(logo)
image_flip(logo)
image_flop(logo)
image_frame(logo)
image_implode(logo)
image_negate(logo)
image_normalize(logo)
image_rotate(logo, 45)
image_fill(image_flatten(logo), "red")
image_fill(image_flatten(logo), "red", fuzz = 25600)
image_chop(logo, "100x20")
image_colorize(logo, 50, "red")
# Lights up the R logo
frames <- image_scale(logo, "400x400")
for(i in 1:7) frames <- c(frames, image_contrast(frames[i]))
(blink <- image_animate(c(frames, rev(frames)), fps = 20, loop = 1))
# Add some text to an image
image_annotate(logo, "This is a test")
image_annotate(logo, "CONFIDENTIAL", size = 50, color = "red", boxcolor = "pink",
degrees = 30, location = "+100+100")
# Setting fonts requires fontconfig support (and that you have the font)
myfont <- ifelse(identical("windows", .Platform$OS.type), "courier-new", "courier")
try(image_annotate(logo, "The quick brown fox", font = myfont, size = 50))
logo2 <- image_blur(logo)
if(magick_config()$version >= "6.8.7")
image_compare(logo, logo2, metric = "phash")
# }
Run the code above in your browser using DataLab