- @echo off
- setlocal enabledelayedexpansion
-
- set "IM=D:\桌面\ImageMagick-7.0.3-0-portable-Q16-x86"
- set "图片目录=PICDIR"
- set "坐标目录=%图片目录%\Placements"
-
- for %%N in (identify convert) do for %%a in ("%IM%\%%N.exe") do set "%%N=%%~sa"
-
- 2>nul md "%~dp0%坐标目录%\"
-
- set /a "cntPic=sumPic=0"
-
- for %%x in (png bmp) do for /f "delims=" %%i in ('2^>nul dir /a-d /b /s "%~dp0%图片目录%\*.%%x" ^| find /v /c ""') do ^
- set /a "sumPic += %%i"
-
- for %%x in (png bmp) do for /f "delims=" %%i in ('2^>nul dir /a-d /b /s "%~dp0%图片目录%\*.%%x"') do (
-
- for /f "tokens=1-2" %%b in ('%identify% -format "%%[fx:w] %%[fx:h]" "%%~i"') do (
-
- set /a "cntPic+=1, 原宽=%%b,原高=%%c"
- title 已完成 !cntPic!/!sumPic! %~nx0 & rem 在标题栏上显示处理进度
- REM echo;%%i
- REM echo;原尺寸:!原宽!,!原高!
-
- REM 剪上部 和 左部 空白
- %convert% "%%~i" -gravity South ^
- -background white -splice 0x1 -background black -splice 0x1 ^
- -trim +repage -chop 0x1 ^
- -gravity East ^
- -background white -splice 1x0 -background black -splice 1x0 ^
- -trim +repage -chop 1x0 ^
- "%%~i"
-
- for /f "tokens=1-2" %%b in ('%identify% -format "%%[fx:w] %%[fx:h]" "%%~i"') do (
- set /a "x = 原宽-%%b, y = 原高-%%c"
- >"%~dp0%坐标目录%\%%~ni.txt" (echo;!x!& echo;!y!)
- )
-
- REM 一次性裁剪掉四边空白
- %convert% "%%~i" -gravity SouthEast ^
- -background white -splice 0x0 -background black -splice 0x0 ^
- -trim +repage -chop 0x0 "%%~i"
-
- REM 剪下部和右部空白
- REM %convert% "%%~i" -gravity North ^
- REM -background white -splice 0x1 -background black -splice 0x1 ^
- REM -trim +repage -chop 0x1 ^
- REM -gravity West ^
- REM -background white -splice 1x0 -background black -splice 1x0 ^
- REM -trim +repage -chop 1x0 ^
- REM "%%~i"
-
- )
- )
- echo;!cntPic!/!sumPic! 已完成处理
-
- pause
- exit
-
-
-
-
- REM 一次性裁剪掉四边空白
- REM %convert% "d:\test.png" -gravity SouthEast ^
- REM -background white -splice 0x0 -background black -splice 0x0 ^
- REM -trim +repage -chop 0x0 "d:\test.png"
-
-
- REM 剪上部空白
- %convert% "D:\test.png" -gravity South ^
- -background white -splice 0x1 -background black -splice 0x1 ^
- -trim +repage -chop 0x1 "d:\trim_South.png"
-
- REM 剪左部空白
- %convert% "d:\trim_South.png" -gravity East ^
- -background white -splice 1x0 -background black -splice 1x0 ^
- -trim +repage -chop 1x0 "d:\trim_SouthEast.png"
复制代码
|