Preview a saved PNG in an R device window

You can import it and display it in R,

library(png)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
grid::grid.raster(img)

Baptiste's answer didn't work for me while using RStudio in Linux. I had to remove the system.file() call.

library(png)
img <- readPNG('/path/image.png')
grid::grid.raster(img)

Use ImageMagick library for all your image processing needs. It is brought to you as magick package to R. See the introductory vignette.

install.packages('magick')

img <- magick::image_read('/path/image.png')
plot(img) # or print(img)

Tags:

R