# The magick package: Advanced Image-Processing in R # 2018-03-19 # https://cran.r-project.org/web/packages/magick/vignettes/intro.html # # Installing magick # On Windows or OS-X the package is most easily installed via CRAN. install.packages("magick") str(magick::magick_config()) # Build from source # sudo apt-get install libmagick++-dev # Read and write library(magick) tiger <- image_read_svg('http://jeroen.github.io/images/tiger.svg', width = 400) print(tiger) # Render svg to png bitmap image_write(tiger, path = "tiger.png", format = "png") # Converting formats tiger_png <- image_convert(tiger, "png") image_info(tiger_png) # Cut and 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, "hotpink"), "#000080", "20x10") # Trim margins image_trim(frink) # Passport pica image_crop(frink, "100x150+50") # Resize image_scale(frink, "300") # width: 300px image_scale(frink, "x300") # height: 300px # Rotate or mirror image_rotate(frink, 45) image_flip(frink) image_flop(frink) # Brightness, Saturation, Hue image_modulate(frink, brightness = 80, saturation = 120, hue = 90) # Paint the shirt orange image_fill(frink, "orange", point = "+100+200", fuzz = 20)