Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Convert .svg to .png in Alteryx?

Seffana_
7 - Meteor

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. 

5 REPLIES 5
JohnJPS
15 - Aurora

Hi @Seffana_.

 

If you have R installed, I would recommend using either convertGraph or rsvg package.

 

Hope that helps!

John

 

Seffana_
7 - Meteor

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?

attempt.png

 

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

JohnJPS
15 - Aurora

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.

 

Seffana_
7 - Meteor

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.

 

1.png

 

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. 2.png

 

 

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

 

 

JohnJPS
15 - Aurora

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

 

Labels
Top Solution Authors