Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Commandline tool to convert svg files to png with optional scaling  (Read 6407 times)

0 Members and 1 Guest are viewing this topic.

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
I'm posting a simple,and stupid command-line utility https://github.com/degski/svg2png to convert svg to png (as SFML does not support that format out of the box and there seem to be few on the ground).

It is based on sf-svg, all the credits go to Kamil Koczurek (github.com/kamirr).

I've released a 64-bit statically linked windows executable [in the releases section of the github repository], virustotal.com report linked.

If you have a folder of svg-files to convert (I had 222 of them), this saves you loads of time, and the results are altogether satisfying.
« Last Edit: August 02, 2019, 12:42:59 pm by degski »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Commandline tool to convert svg files to png with optional scaling
« Reply #1 on: August 02, 2019, 07:20:36 pm »
ImageMagick can do it too if you have it installed or are willing to install it.

I once had a bunch of bmp files and wrote a similar tool to go from bmp, jpg, etc. to png ( https://github.com/FRex/topng/ ) because I didn't have ImageMagick and didn't want to install it just for this, but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) but mine is at least simple to invoke in find command or something.
Back to C++ gamedev with SFML in May 2023

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Commandline tool to convert svg files to png with optional scaling
« Reply #2 on: August 03, 2019, 06:18:44 am »
> ... but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) ...

Same here, I have that installed as well (and did not know about it!).

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Commandline tool to convert svg files to png with optional scaling
« Reply #3 on: August 03, 2019, 06:44:19 am »
To be clear: ffmpeg can do jpeg and others to png. It can't do svg to png. ImageMagick can.
Back to C++ gamedev with SFML in May 2023

degski

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Commandline tool to convert svg files to png with optional scaling
« Reply #4 on: August 03, 2019, 10:52:55 am »
I was just gonna ask you what the magic incantations were, because I did not find them in the help screens.

So, one cannot convert svg to png using ffmpeg.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Commandline tool to convert svg files to png with optional scaling
« Reply #5 on: August 03, 2019, 11:30:42 am »
Wouldn't be surprised if ffmpeg could somehow also convert SVG. Seems like Inkscape is also a good alternative: https://stackoverflow.com/questions/9853325/how-to-convert-a-svg-to-a-png-with-image-magick
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/