Last active
April 23, 2020 18:16
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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