Window's shell script to quickly convert SVG's to PNGs
Wanted to share the following Window's shell script as a quick way to convert SVG's to pngs, using inkscape...
@echo off
setlocal
REM Set input and output file paths
set "input_file=%~1"
set "output_png=%~dp1%~n1.png"
REM Log file
set "log_file=%~dp1conversion_log.txt"
> "%log_file%" (
echo Starting conversion...
echo Input file: "%input_file%"
echo Output PNG: "%output_png%"
)
REM Process the SVG file with Inkscape
echo Processing "%input_file%" with DPI 150... >> "%log_file%"
inkscape "%input_file%" --export-type="png" --export-filename="%output_png%" --export-dpi=150 --export-background=white >> "%log_file%" 2>&1
REM Check if PNG conversion was successful
if exist "%output_png%" (
echo Successfully converted to PNG: "%output_png%" >> "%log_file%"
echo Conversion complete: "%output_png%" >> "%log_file%"
) else (
echo Error occurred during PNG conversion. Please check the log for details. >> "%log_file%"
)
REM Wait for user input before closing
echo Press any key to continue...
pause > nul
How to Set Up for Context Menu
Save the Script: Save this updated script as
convert_svg_to_png.bat
in a known location.Add a Context Menu Entry:
Press
Win + R
, typeregedit
, and pressEnter
to open the Registry Editor.Navigate to
HKEY_CLASSES_ROOT\*\shell
.Right-click on
shell
, then selectNew > Key
, and name itConvert SVG to PNG
.Right-click on the new
Convert SVG to PNG
key, selectNew > Key
, and name this onecommand
.Double-click on the
(Default)
value under thecommand
key and set its value to the path of your batch script. Wrap the path in quotes and add%1
like this:"C:\path\to\convert_svg_to_jpg.bat" "%1"
Comments
I haven't figured how to have it process multiple selected svg's at one time, if anyone has a clue.
got it to work with multiple svgs as once, but you have to drag and drop the svgs onto the .bat script.
see attached video.
Hello guys, I have taken @theoryshaw script and enhanced it a little bit with the help of A.I to create a basic working UI. The script works well and it's a standalone .exe file. I tried implementing svg to jpeg and tiff formats but there were many bugs with it that i could not fix. But as far as Svg to Png and Pdf are concerned, it works well. There are a few iterations, the other interations you might see in the repo are python script and might require running it as these in the in the terminal
python svg_to_png_gui_G.py
python svg_to_png_gui.py-C-v2.py
python svg_to_png_gui_D-v2-NewTheme.py
python svg_to_png_gui_G-v2-NewTheme.py
python svg_to_png_gui_G-v3-NewTheme.py
python svg_to_png_gui_G-v4-NewTheme.py
python svg_to_png_gui_G-v5-NewTheme.py
python svg_to_png_gui_G-v6-NewTheme.py
python svg_to_png_gui_G-v7-NewTheme.py
But the main script here




https://hub.openingdesign.com/OpeningDesign/Utility_Apps/src/branch/main/Svg2PngPdf/dist/SVGtoPNGConverter.exe
Here are a few screenshots. The other version do have other themes attempts to it, i even tried to implement a theme that looked more like bonsai, but that was beyond me with the amount of bugs and troubleshoot and the output result wasn't so great.