library(magick)
## Linking to ImageMagick 6.9.12.3
## Enabled features: cairo, freetype, fftw, ghostscript, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fontconfig, x11
str(magick::magick_config())
## List of 24
##  $ version           :Class 'numeric_version'  hidden list of 1
##   ..$ : int [1:4] 6 9 12 3
##  $ modules           : logi FALSE
##  $ cairo             : logi TRUE
##  $ fontconfig        : logi FALSE
##  $ freetype          : logi TRUE
##  $ fftw              : logi TRUE
##  $ ghostscript       : logi TRUE
##  $ heic              : logi TRUE
##  $ jpeg              : logi TRUE
##  $ lcms              : logi TRUE
##  $ libopenjp2        : logi TRUE
##  $ lzma              : logi TRUE
##  $ pangocairo        : logi TRUE
##  $ pango             : logi TRUE
##  $ png               : logi TRUE
##  $ raw               : logi TRUE
##  $ rsvg              : logi TRUE
##  $ tiff              : logi TRUE
##  $ webp              : logi TRUE
##  $ wmf               : logi FALSE
##  $ x11               : logi FALSE
##  $ xml               : logi TRUE
##  $ zero-configuration: logi TRUE
##  $ threads           : int 1

Transformations Cara terbaik untuk memahami transformasi yang tersedia adalah menelusuri contoh di ?transformationshalaman bantuan di RStudio. Di bawah ini beberapa contoh untuk memahami apa yang mungkin.

Cut and Edit

Beberapa fungsi transformasi mengambil geometry parameter yang memerlukan sintaks khusus dari bentuk AxB+C+Ddi mana setiap elemen bersifat opsional. Beberapa contoh:

image_crop(image, “100x150+50”): pangkas width:100pxdan height:150pxmulai +50pxdari kiri image_scale(image, “200”): mengubah ukuran secara proporsional dengan lebar:200px image_scale(image, “x200”): mengubah ukuran secara proporsional dengan tinggi:200px image_fill(image, “blue”, “+100+200”): banjir isi dengan warna biru mulai dari titik dix:100, y:200 image_border(frink, “red”, “20x10”): menambahkan batas 20px kiri+kanan dan 10px atas+bawah

frink <- image_read("https://jeroen.github.io/images/frink.png")
print(frink)
##   format width height colorspace matte filesize density
## 1    PNG   220    445       sRGB  TRUE    73494   72x72

image_border(image_background(frink, "hotpink"), "#000080", "20x10")

image_crop(frink, "150x150+10")

Rotate or mirror

image_rotate(frink, 90)

image_flop(frink)

Brightness, Saturation, Hue

image_modulate(frink, brightness = 100, saturation = 50, hue = 90)

paint the shirt orange

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

Text annotation

add some text

image_annotate(frink, "I like LinierAlgebra!", size = 70, gravity = "southwest", color = "green")

costumize text

image_annotate(frink, "Nabil Hilmi", size = 30, color = "red", boxcolor = "pink",
  degrees = 60, location = "+50+100")

Fonts may require ImageMagick has fontconfig

image_annotate(frink, "Hello World", font = 'Times', size = 30)

Font yang didukung pada sebagian besar platform meliputi “sans”, “mono”, “serif”, “Times”, “Helvetica”, “Trebuchet”, “Georgia”, “Palatino”atau “Comic Sans”.