我们常常需要转化图片的格式,虽然用Windows自带的画图工具就可以实现,但是如果有大量的图片需要转化的时候呢?那就是WIA的Convert滤镜(Filter)大显身手的时候了。
Const wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" Const wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" Const wiaFormatGIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" Set Img = CreateObject("WIA.ImageFile") Set IP = CreateObject("WIA.ImageProcess") Img.LoadFile "test.bmp" IP.Filters.Add IP.FilterInfos("Convert").FilterID IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG Set Img = IP.Apply(Img) Img.SaveFile "test.jpg"
参考链接:Convert Filter: Create a Compressed JPEG File from Another File