Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created July 8, 2011 16:57
Show Gist options
  • Save xulapp/1072261 to your computer and use it in GitHub Desktop.
Save xulapp/1072261 to your computer and use it in GitHub Desktop.
optpng
@echo off
:mainloop
if "%~1" == "" goto :eof
call :optimize "%~1"
shift
goto :mainloop
:optimize
set a=%~a1
if "%a:~0,1%" == "d" (
for /r "%~1" %%i in ("*.png") do call :optimize "%%~i"
goto :eof
)
set tmpfile="%temp%\optpngtmp-%random:~-1%%random:~-1%%random:~-1%%random:~-1%%random:~-1%.png"
flaxc.exe "%~1" "%~1" -P256 -D4 -R1 > nul
pngrewrite.exe "%~1" "%~1" 2> nul
optipng.exe -o7 -quiet "%~1"
pngout.exe "%~1" /y /q
cpngc.exe "%~1" %tmpfile% > nul
copy /y %tmpfile% "%~1"
del %tmpfile%
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment