*!*
调整图像分辨率和调整图像质量的两个函数:
Clear
inFile = Getfile("JPG")
&& 源图像文件名,可以直接指定文件名,比如:inFile = "C:\Temp\MyImageJPG"
outFile = "Temp.Jpg"
&& 目标图像文件名,可以指定盘符和路径名
tnW = 225
&& 目标图像宽
tnH = 400
&& 目标图像高
=Resolution(inFile, outFile, tnW, tnH)
&& 四个参数,不可缺。
*!*
1. 调整图像分辨率
Function Resolution(inFile As Character, outFile As Character, tnW As Integer, tnH As Integer)
Local Img
&& As ImageFile
Local IP
&& As ImageProcess
Img = Createobject("WIA.ImageFile")
IP = Createobject("WIA.ImageProcess")
Img.LoadFile(inFile)
*!*
大小/调整分辨率:
IP.Filters.Add(IP.FilterInfos("Scale").FilterID)
IP.Filters(1).Properties("MaximumWidth") = tnW
IP.Filters(1).Properties("MaximumHeight") = tnH
Img = IP.Apply(Img)
Delete File &outFile
Img.SaveFile(outFile)
*!*
比较压缩调整前后的文件大小
=Adir(gaJPG, inFile)
? "调整前的文件大小 : " + Transform(gaJPG(2)/1024) + "KB"
=Adir(gaJPG, outFile)
? "调整后的文件大小 : " + Transform(gaJPG(2)/1024) + "KB"
? "完成."
Endfunc