rmagick

What am I doing wrong that is throwing an "Error in fun(file) : Unsupported file format." error


I have a folder of images, all .jpeg, which I am trying to load into R. I am getting the following error

Error in fun(file) : Unsupported file format.
Please convert to jpeg/png/bmp or install image magick

I have tried reinstalling the imager and magick packages, neither has solved the issue.

In the Files tab of RStudio I have made sure that the images exist there and are selected.

library(imager)
library(magick)

image1 = load.image('image1.jpeg')
plot(image1)

I would expect to see the image pop up in the plots tab, but it is not.


Solution

  • Use magick's image_read() instead:

    image <- image_read("./path/image.jpeg")
    

    If it doesn't read, then as some of the comments say it may not be the right format.