ImageMagick binaries available here.
convert ...
Save this as something like Image Converter.bat
and drop it in the same directory as your images. Optimized images will be generated in the "Output" folder.
@echo off
setlocal enabledelayedexpansion
title Image Converter
:initialize
where convert>nul
if %ERRORLEVEL% neq 0 goto errorInit
if not exist "%cd%/Output" mkdir "%cd%/Output"
:format
set /a count = 0
for %%f in (*.jpg *.png *.gif) do (
echo Processing %%f...
convert ...
if %ERRORLEVEL% neq 0 goto errorFormat
set /a count += 1
)
echo ^> !count! image(s) formatted successfully
goto eof
:errorInit
echo ^> ImageMagick is not installed on your system. Get a binary at:
echo https://www.imagemagick.org/download/binaries/
goto eof
:errorFormat
echo Error converting file!
goto eof
:eof
pause>nul
endlocal
exit /B
sudo apt install imagemagick # Debian-based
sudo yum install imagemagick # CentOS/RHEL
brew install imagemagick # macOS
convert ...
#!/bin/bash
cd "$(dirname "$0")" || return
if [[ -n "$(command -v convert)" ]]; then
echo " > ImageMagick is not installed on your system. Install it with:" >&2
if [[ -n "$(command -v apt-get)" ]]; then echo " sudo apt-get install imagemagick"; fi
if [[ -n "$(command -v yum)" ]]; then echo " sudo yum install imagemagick"; fi
if [[ -n "$(command -v brew)" ]]; then echo " brew install imagemagick"; fi
exit 1
fi
mkdir -p output > /dev/null
count=0
for i in *.jpg *.png *.gif; do
echo "Processing $i..."
convert ...
if [ $? -ne 0 ]; then
echo "Error converting file!" >&2
exit 2
fi
(( count += 1 ))
done
echo " > $count image(s) formatted successfully"