Reputation: 52308
Is there a convenient way to convert a .png
to .svg
using only base R or CRAN functions?
Currently I'm using an external (point and click) program to convert images. Would be very handy to be able to do so in R
Upvotes: 5
Views: 1811
Reputation: 992
You are looking for the image_convert
function from the magick
package. Check the package description and the 'Converting formats' section from the package vignette.
Actually it is using 'ImageMagick', an open-source image processing library worth a look itself.
library(magick)
my_image <- image_read("image.png")
my_svg <- image_convert(my_image, format="svg")
image_write(my_svg, "image.svg")
dir()
[1] "image.png" "image.svg"
Upvotes: 7