Create a gist now

Instantly share code, notes, and snippets.

@smison /resize.bat
Last active Aug 29, 2015

What would you like to do?
同じディレクトリのpng画像を長辺900pxにリサイズするbatファイル(http://qiita.com/smison/items/d32eb72be807e099dfa0)
setlocal enabledelayedexpansion
for %%f in (*.png) do (
REM 画像の縦幅を取得
for /f "usebackq tokens=*" %%i in (`identify -format '%%h' %%f`) do @set HEIGHT=%%i
REM 画像の横幅を取得
for /f "usebackq tokens=*" %%i in (`identify -format '%%w' %%f`) do @set WIDTH=%%i
if !HEIGHT! GEQ !WIDTH! (
REM 縦幅 >= 横幅
convert -resize x900 %%f %%~nf_resized.png
) else (
REM 縦幅 < 横幅
convert -resize 900x %%f %%~nf_resized.png
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment