Skip to content

Instantly share code, notes, and snippets.

@sixlettervariables
Last active August 29, 2015 14:04
Show Gist options
  • Save sixlettervariables/d44d5ab17aa34b612aae to your computer and use it in GitHub Desktop.
Save sixlettervariables/d44d5ab17aa34b612aae to your computer and use it in GitHub Desktop.
Batch thumbnail creation with ImageMagik's mogrify and OptiPNG (non-recursive, needs thumbs directory)
::
:: Non-recursive ImageMagick mogrify thumbnail batch conversion,
:: with OptiPNG compression afterwards.
:: Based on http://superuser.com/a/604502
::
:: Caveats: 1. Will reduce colorspace if possible (Color -> Grays)
:: 2. Will overwrite thumbnails in-place if they exist
:: 3. Requires %1\thumbs to exist
:: 4. Uses 30% of original size, change as you see fit
::
@echo off
echo.
set mogrify_apppath="mogrify.exe"
set OptiPNG_apppath="OptiPNG.exe"
if [%1]==[] echo Usage: %0 "PNG Dir" && echo. && echo Error: Invalid parameters && goto :EOF
if not exist %1 echo Usage: %0 "PNG Dir" && echo. && echo Error: Invalid directory "%~1" && goto :EOF
%mogrify_apppath% -verbose -format png -path "%~1\thumbs" -thumbnail 30%% "%~1\*.png"
%OptiPNG_apppath% "%~1\thumbs\*.png" -zc9 -zm9 -zs3 -f0-5 -strip "all"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment