Skip to content

Instantly share code, notes, and snippets.

@Rplus
Last active December 21, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rplus/6279394 to your computer and use it in GitHub Desktop.
Save Rplus/6279394 to your computer and use it in GitHub Desktop.
image minify in windows
# gif > png8
@echo off
set CONVERT=D:\Software\PIC\ImageMagick-6.8.3-6\convert.exe
for %%a in (%*) do (
dir /a %%a|findstr "DIR" >nul 2>nul && (
"%CONVERT%" %%a "%%~dpna.png\*"
) || (
"%CONVERT%" %%a "%%~dpna.png"
)
)
# jpg > tran > progressive jpeg
@echo off
set JPEGtran=D:\Software\PIC\jpegtran\jpegtran.exe
for %%a in (%*) do (
dir /a %%a|findstr "DIR" >nul 2>nul && (
"%JPEGtran%" -copy none -optimize -perfect %%a "%%~dpna_tran%%~xa"
rename "%%~na%%~xa" "%%~na_0%%~xa"
"%JPEGtran%" -copy none -optimize -perfect -progressive "%%~dpna_tran%%~xa" "%%~dpna_tran_p%%~xa\*"
) || (
"%JPEGtran%" -copy none -optimize -perfect %%a "%%~dpna_tran%%~xa"
rename "%%~na%%~xa" "%%~na_0%%~xa"
"%JPEGtran%" -copy none -optimize -perfect -progressive "%%~dpna_tran%%~xa" %%~dpna_tran_p%%~xa
)
)
# png > 8bit > crush
set PNGquant=D:\Software\PIC\PNGquant\pngquant.exe
set PNGcrush=D:\Software\PIC\pngcrush\pngcrush.exe
for %%a in (%*) do (
dir /a %%a|findstr "DIR" >nul 2>nul && (
"%PNGquant%" -ext _8bit.png -iebug -force -verbose 256 %%a
rename "%%~na%%~xa" "%%~na_0%%~xa"
"%PNGcrush%" -rem alla -brute -reduce "%%~dpna_8bit%%~xa" "%%~dpna%%~xa\*"
) || (
"%PNGquant%" -ext _8bit.png -iebug -force -verbose 256 %%a
rename "%%~na%%~xa" "%%~na_0%%~xa"
"%PNGcrush%" -rem alla -brute -reduce "%%~dpna_8bit%%~xa" %%~dpna%%~xa
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment