imagemagick 批量旋转图片 转为横版式

 

批处理脚本 保存为文件rotate.bat 放置于要处理的图片目录

在命令行下调用 rotate 目录名

例如 roatate img

将img文件夹中的所有文件改为横版,宽度大于高度。

 

echo off

setlocal enabledelayedexpansion

echo ============rotate start============

 

::src forder

set srcForder=%1

::des forder

set desForder=p_%srcForder%_p

 

md %desForder%

cd %srcForder%

 

for /f %%i in ('dir /b *.jpg') do (

 

set src=%%i

set des=../%desForder%/%%i

 

identify -ping -format %%[fx:w] !src!>tmp

set /p width=<tmp

identify -ping -format %%[fx:h] !src!>tmp

set /p height=<tmp

echo !src! width=!width!,height=!height!

::if width gtr height

if !width! lss !height! (

convert !src! -rotate -90 !des!

echo rotate...

) else (

copy !src! !des!>nul

echo copy...

)

)

 

del tmp

 

echo ============rotate   end============

 

posted @ 2011-04-03 11:39  OYJJ  阅读(623)  评论(0编辑  收藏  举报