ResizeImg.vbs
Set oImg = CreateObject("WIA.ImageFile")
Set oProc = CreateObject("WIA.ImageProcess")
oImg.LoadFile "Water lilies.jpg" '打开当前文件夹里的Water lilies.jpg
oProc.Filters.Add oProc.FilterInfos("Scale").FilterID '添加一个 Scale 的滤境
oProc.Filters(1).Properties("MaximumWidth")="400" '定义新图片的 宽
oProc.Filters(1).Properties("MaximumHeight")="300" '定义新图片的 高
Set oNewImg = oProc.Apply(oImg) '保存新图片到 oNewImg 对象里
oNewImg.SaveFile "New.jpg" '把oNewImg对象保存为图片
测试系统:Windows XP SP2 WSH 5.6,只要安装了 Windows Image Acquisition 的操作系统都可以成功运行。 Windows ME XP 都是默认安装WIA的。
其中 Water lilies.jpg 是 XP 自带的“示例图片”,运行vbs脚本时请确认复制Water lilies.jpg到当前脚本所在的文件夹
下次节目精彩提示:用vbs转换图片格式,摄像头截图,字符识别,语音识别……感兴趣者可以加入到我们的QQ讨论群里:21154458 。注意:本群只欢迎真心探讨、学习vbs的朋友,不是用来解答批处理/vbs问题的。
Last edited by electronixtar on 2006-10-24 at 11:23 PM ]
ResizeImg.vbs
Set oImg = CreateObject("WIA.ImageFile")
Set oProc = CreateObject("WIA.ImageProcess")
oImg.LoadFile "Water lilies.jpg" 'Open the Water lilies.jpg in the current folder
oProc.Filters.Add oProc.FilterInfos("Scale").FilterID 'Add a Scale filter
oProc.Filters(1).Properties("MaximumWidth")="400" 'Define the new image width
oProc.Filters(1).Properties("MaximumHeight")="300" 'Define the new image height
Set oNewImg = oProc.Apply(oImg) 'Save the new image to the oNewImg object
oNewImg.SaveFile "New.jpg" 'Save the oNewImg object as an image
Test system: Windows XP SP2 WSH 5.6, can run successfully on any operating system that has Windows Image Acquisition installed. Windows ME and XP have WIA installed by default.
Among them, Water lilies.jpg is the "Sample Picture" included with XP. Please make sure to copy Water lilies.jpg to the folder where the script is located when running the vbs script.
Next program exciting tips: Convert image format with vbs, webcam screenshots, character recognition, speech recognition... Those who are interested can join our QQ discussion group: 21154458. Note: This group only welcomes friends who are sincerely discussing and learning vbs, not for answering batch processing/vbs questions.
Last edited by electronixtar on 2006-10-24 at 11:23 PM ]