Bindings to ImageMagick: the most comprehensive open-source image
processing library available. Supports many common formats (png, jpeg, tiff,
pdf, etc) and manipulations (rotate, scale, crop, trim, flip, blur, etc).
All operations are vectorized via the Magick++ STL meaning they operate either
on a single frame or a series of frames for working with layers, collages,
or animation. In RStudio images are automatically previewed when printed to
the console, resulting in an interactive editing environment.
Run examples in RStudio to see live previews of the images! If you do not use RStudio, use image_browse to open images. On Linux you can also use image_display to get an X11 preview.
library(magick)
frink <- image_read("https://jeroen.github.io/images/frink.png")
image_trim(frink)
image_scale(frink, "200x200")
image_flip(frink)
image_rotate(frink, 45) ## <-- result of this is shown
image_negate(frink)
frink |>
image_background("green") |>
image_flatten() |>
image_border("red", "10x10")
earth <- image_read("https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif")
length(earth)
earth[1]
earth[1:3]
earth1 <- rev(image_flip(earth)) ## How Australians see earth
image_write(earth1, "man/figures/earth1.gif") ## <-- result of this is shown
Binary packages for macOS or Windows can be installed directly from CRAN:
install.packages("magick")
Installation from source on Linux or OSX requires the imagemagick Magick++ library. On Debian or Ubuntu install libmagick++-dev:
sudo apt-get install -y libmagick++-dev
On Fedora, CentOS or RHEL we need ImageMagick-c++-devel. However on CentOS the system version of ImageMagick is quite old. More recent versions are available from the ImageMagick downloads website.
rOpenSci: The magick package
Bindings to ImageMagick: the most comprehensive open-source image processing library available. Supports many common formats (png, jpeg, tiff, pdf, etc) and manipulations (rotate, scale, crop, trim, flip, blur, etc). All operations are vectorized via the Magick++ STL meaning they operate either on a single frame or a series of frames for working with layers, collages, or animation. In RStudio images are automatically previewed when printed to the console, resulting in an interactive editing environment.
Documentation
About the R package:
About the underlying library:
Hello World
Run examples in RStudio to see live previews of the images! If you do not use RStudio, use
image_browseto open images. On Linux you can also useimage_displayto get an X11 preview.Effects
Create GIF animation:
Read GIF animation frames. See the rotating earth example GIF.
R logo with dancing banana
Use magick in Shiny Apps
This demo application shows how to use magick with shiny: https://github.com/jeroen/shinymagick
Installation
Binary packages for macOS or Windows can be installed directly from CRAN:
Installation from source on Linux or OSX requires the imagemagick
Magick++library. On Debian or Ubuntu install libmagick++-dev:On Fedora, CentOS or RHEL we need ImageMagick-c++-devel. However on CentOS the system version of ImageMagick is quite old. More recent versions are available from the ImageMagick downloads website.
On macOS use imagemagick@6 from Homebrew.
The unversioned homebrew formula
imagemagickcan also be used, however it has some unsolved OpenMP problems.There is also a fork of imagemagick called graphicsmagick, but this doesn’t work for this package.