0

VBS图片处理之用VBS转化图片格式

Posted by 晴云孤魂 on 2013 年 03 月 11 日 in Literary corner |

我们常常需要转化图片的格式,虽然用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"

Copyright © 2011-2021 晴云孤魂's Blog All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.

普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress