Skip to main content
edited title
Link
Toto
  • 18.3k
  • 73
  • 33
  • 45

Àdd Add a new ImageMagick command in an existing batch file

Source Link

Àdd a new ImageMagick command in an existing batch file

I have this batch file:

for %%f in (*.svg) do (

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=256 ^
  --export-png="%%~nf_256x256.png" ^
  --file="{%%~f}"  

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=128 ^
  --export-png="%%~nf_128x128.png" ^
  --file="%%~f"  

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=64 ^
  --export-png="%%~nf_64x64.png" ^
  --file="%%~f" 

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=48 ^
  --export-png="%%~nf_48x48.png" ^
  --file="%%~f" 

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=32 ^
  --export-png="%%~nf_32x32.png" ^
  --file="%%~f" 

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=24 ^
  --export-png="%%~nf_24x24.png" ^
  --file="%%~f"  

"C:\Program Files\Inkscape\inkscape.com" ^
  -z ^
  --export-background-opacity=0 ^
  --export-height=16 ^
  --export-png="%%~nf_16x16.png" ^
  --file="%%~f" 

"C:\Program Files\ImageMagick-7.0.7-Q16\magick.exe" convert %%~nf_16x16.png %%~nf_24x24.png %%~nf_32x32.png %%~nf_64x64.png %%~nf_128x128.png %%~nf_256x256.png %%~nf.ico)

What it does:

  1. Convert every single .svg in the folder to multiple .png's in different sizes
  2. Combine these .png's into a single .ico

Software used: ImageMagick and Inkscape.

Now there is another 'command' I want to add:

mogrify -units "PixelsPerInch" -density 96 *.png

This script converts the ppi of every png to 96. This needs to happen before the conversion to .ico

I also have this batch file:

@echo off
Setlocal enabledelayedexpansion

Set "Pattern= "
Set "Replace=_"

For %%a in (*.svg) Do (
    Set "File=%%~a"
    Ren "%%a" "!File:%Pattern%=%Replace%!"
)

Pause&Exit

This replaces file name spaces with an underscore. Which needs to happen at first before conversion to .png.

How do I add/combine this into a single batch file?