Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active April 23, 2020 18:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tresf/1bd76fc8cd4a4def215c68cab990dfb1 to your computer and use it in GitHub Desktop.
@echo off
REM See also: https://superuser.com/a/1545028/443147
set resolution=72
set width=400
set height=600
REM Find Gimp in the registry
for /f "tokens=2*" %%a in ('reg query "HKCR\GIMP2.svg\shell\open\command" /ve 2^>^&1^|find "REG_"') do @set gimp=%%b
REM Calculate console exe
set gimp=%gimp:gimp-=gimp-console-%
REM Isolate exe
for %%i in (%gimp%) do (
@set gimp=%%i
goto :found
)
:found
echo Found Gimp console: %gimp%
REM Process files (change to "for /r %%i" for recursion)
for %%i in (*.svg) do (
echo - Converting [ %%i --^> %%~ni.png ] ^(%width%x%height%@%resolution%^)
%gimp% -i -b "(let* ((image (car (file-svg-load RUN-NONINTERACTIVE \"%%i\" \"\" 72 (- 0 400) (- 0 600) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable \"%%~ni.png\" \"%%~ni.png\") (gimp-image-delete image))" -b "(gimp-quit 0)"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment