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"
-