Hello,
Does anyone know if there is a way to convert .svg (Scalable Vector Graphics) images to .png in Alteryx?
I have scraped and downloaded a load of images, all of which are .svg files. I wanted to know if there is a way to convert them to .png in the same workflow rather than finding an online converter on the web.
Solved! Go to Solution.
Hi @Seffana_.
If you have R installed, I would recommend using either convertGraph or rsvg package.
Hope that helps!
John
Hi @JohnJPS ,
Thanks for responding.
For someone who is totally unfamiliar with R, do you mean that I should use the R tool in Alteryx or the actual application on my PC?
Feel free to ignore the code in the R tool. I just wanted to show you my workflow if it helps picture what I would like to do.
Many thanks,
Seffana
I think the R-tool within Alteryx will work... I ran a quick test where, given some .svg files in a directory, I pulled them in using the Directory tool, then created an output path for the corresponding .png files using a formula tool with:
Replace([FullPath],".svg",".png")
Then, feed into the R tool, with the following R code:
#install.packages("rsvg")
library("rsvg")
dfIn = read.Alteryx("#1", mode="data.frame")
for (i in 1:nrow(dfIn)) {
rsvg_png(as.character(dfIn$FullPath[i]),
as.character(dfIn$pngFullPath[i]))
}
write.Alteryx(dfIn, 1)
The first line is commented out using the pound sign... the first time you run this, you may need to uncomment that, in order to get the 'rsvg' package added to your R environment. Afterwards, you can comment it back out using the pound sign. From there, hopefully the code is easy enough to follow even if unfamiliar with R...
This is all in the attached workflow; in order for it to work, you'll need to point it at a directory of .svg images.
Hi John,
Thank you very much! This worked!
I just wanted to say that I had issues getting the rsvg package to install on the R tool via Alteryx. I'll put down what my colleague, @BenMoss, helped me with to make it work in case anyone else comes to this post experiencing the same issue.
An alternate method to installing rsvg on R:
1) For those who uses Windows, go to the following file directory:
C:\Program Files\Alteryx\R-3.4.4\bin
2) Right-click on R.exe and click on Run as administrator.
3) Insert and run the following in the command window:
install.packages("rsvg")
4) Select a mirror that is closest to you, in my case that would London.
5) After the process has run, close the Command window. The package should now be installed.
After I did that, the Alteryx workflow had no errors with the rsvg package.
Once again, thank very much @JohnJPS! :D
Hi @Seffana_,
Great sleuth-work! I had to do that too, but was hoping you wouldn't need to (mostly because I was too lazy to type it all in).
Thanks for posting all the details - it will be really helpful to other users. :-)
- John
User | Count |
---|---|
17 | |
15 | |
15 | |
8 | |
5 |