首先下载安装ImageMagick
http://www.imagemagick.org/script/download.php
这个是一个开源的图像处理软件和库。支持命令行方式运行。安装时确保注册了环境变量。
其实就是path中包含convert.exe的目录即可。
这个convert.exe可以支持各种图像处理操作。这个给出一个图像文件格式的例子。
很简单,比如要把1.bmp转为1.png
convert 1.bmp 1.png
为了实现批量转换写两个批处理
1.bmp2png_muli.bat 实现文件夹遍历和bmp2png调用
cls
echo off
setlocal enabledelayedexpansion
for /f %%i in ('dir /ad /b') do (
call bmp2png %%i
)
实现文件家中*.bmp文件的遍历和转换
echo off
setlocal enabledelayedexpansion
echo ============convert start============
::src forder
set srcForder=%1
::des forder
set desForder=p_%srcForder%_p
md %desForder%
cd %srcForder%
for /f %%i in ('dir /b *.bmp') do (
set src=%%i
set des=..\%desForder%\%%~ni.png
convert !src! !des!
echo !src! !des!
)
)
echo ============convert end============