本帖最后由 hfg1977 于 2012-4-30 21:14 编辑
- @rem (主要用于剪掉MOKO下边缘logo.)
- @goto start
- :help
- @echo.===== Ver: 1.1 =========================== 发布日期: 2010-09-24 =======
- @echo. BAT_NAME: 图片剪切.bat
- @echo. 返回值:
- @echo. 作用 : 图片剪切
- @echo. 调用: 图片剪切.bat [Path...] [file...]
- @echo. [Path]: 文件夹路径
- @echo. [file]: 文件
- @echo.====================== Copyright@ by hf-g ========= [彭城] ============
- ping /n 4 127.0>nul
- goto:end
- :start ============================================================
- @echo off&setlocal
- path=%path%;%~d0\DOS\command\第三方命令行程序
- set "nconvert=E:\DOS\command\第三方命令行程序\nconvert.exe"
- ::==================ADD REG===============================
- for /f "skip=4 tokens=3" %%a in ('REG QUERY "HKLM\Software\hf'file" /v CUT_pic 2^>nul') do set KEY_v=%%a
- if "%KEY_v%" LSS "1" (
- reg add "HKLM\SOFTWARE\Classes\Directory\shell\图片剪切&C\command" /ve /d "\"%~f0\" \"%%1\"" /f>nul
- reg add "HKLM\SOFTWARE\Classes\jpegfile\shell\图片剪切&C\command" /ve /d "\"%~f0\" \"%%1\"" /f>nul
- reg add "HKLM\Software\hf'file" /v CUT_pic /d 1 /f>nul
- )
- ::========================================================
- if /i "%~1"=="" goto help
- if /i "%~1"=="-?" goto help
- set "ext="&set "pathname="&set "Dir_name="&set "p_str="&set "bottom_h="
- set /a exit_BL=0,D_count=0,f_count=0
-
- call:get_P %*
- if "%exit_BL%"=="1" goto end
-
- ::竖式图 30: 915→885 910→880
- ::横式图
- set bottom_h=24
- ::set/a bottom_h=1200-1080
- set bottom_w=777
- ::是否保留源文件
- set save_sourFile_BL=0
-
- :lop_err
- if not defined bottom_h (set /p bottom_h=输入底部需要剪掉的高度^(单位:像素^):)
- echo %bottom_h%|findstr "^[0-9][0-9]*$">nul 2>nul||(echo 错误的数值,请重新输入^!&goto lop_err)
-
- ::设置临时文件
- ::set "tmpfname=%~dp0.\%~n0.log"
- ::cd.>"%tmpfname%"
- ::echo 生成日志文件: %tmpfname%
- echo 底部剪掉的高度: %bottom_h% 像素
- echo 正在处理:
- ::========================MAIN============================
- set/a D_count-=1,f_count-=1
- if not "%pathname_0%"=="" (
- set "ext=*.jpg *.bmp"
- for /l %%i in (0,1,%D_count%) do (
- call pushd "%%pathname_%%i%%"
- call echo %%pathname_%%i%%:
- for /f "tokens=* delims=" %%i in ('dir /a-d/b/s %ext%') do (
- call:CUT_pic "%%i"
- )
- popd
- ))
-
- if not "%file_0%"=="" (
- for /l %%i in (0,1,%f_count%) do (
- call:CUT_pic "%%file_%%i%%"
- )
- )
- echo.
- ::pause
- ::left, center, right\#=top, middle, bottom(底), baseline(基线)
- :end ==============================================================
- ::if exist "%tmpfname%" del "%tmpfname%" "%~dp0.\del_list.bat"
- exit /b
- ::=================================================================
- :CUT_pic picfname %bottom_h%
- set/p =%~nx1<nul
-
- ::剪掉下部的
- if "%save_sourFile_BL%"=="1" (
- %nconvert% -quiet -out jpeg -canvas #0 #-%bottom_h% top-left -o "$%%_1" "%~1"
- ) else (
- %nconvert% -quiet -out jpeg -canvas #0 #-%bottom_h% top-left "%~1"
- )
- ::剪掉上部的
- ::for WC3
- ::%nconvert% -quiet -out jpeg -canvas #-%bottom_w% #-%bottom_h% bottom-right "%~1"
-
- ::剪掉两边的
- ::nconvert -quiet -out jpeg -canvas #-777 #0 center -o "$%_1" "F:\pci\桌面\云_28.jpg"
- goto:eof
- ::========================参数设置与获得============================
- :get_p
- ::判断%1是文件夹或文件
- if "%~1"=="" goto:eof
- set "p_str=%~1"
- if exist "%p_str%" (
- if exist "%p_str%.\" (
- call set "pathname_%%D_count%%=%p_str%"&set /a D_count+=1&shift /1&goto get_p
- )
- call set "file_%%f_count%%=%p_str%"&set /a f_count+=1&shift /1&goto get_p
- ) else (
- echo %p_str% 不是一个正确的文件夹路径或文件^!&set /a exit_BL=1&shift /1&goto end
- )
- @echo off
- :get_p_end
- goto:eof
复制代码 随便改改就行了.
-info : 显示信息 这里有宽高信息. |