>aso.Read(3)
ret(0)="JPG"
ret(2)=binval2(aso.Read(2))
ret(1)=binval2(aso.Read(2))
case else:
if left(Bin2Str(bFlag),2)="BM" then
aso.Read(15)
ret(0)="BMP"
ret(1)=binval(aso.Read(4))
ret(2)=binval(aso.Read(4))
else
ret(0)=""
end if
end select
ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""
getimagesize=ret
End Function
Public Function imgW(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
If (fso1.FileExists(pic_path)) Then
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
imgW = arr(1)
end select
Set f1=nothing
else
imgW = 0
End if
Set fso1=nothing
End Function
Public Function imgH(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
If (fso1.FileExists(pic_path)) Then
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
imgH = arr(2)
end select
Set f1=nothing
else
imgH = 0
End if
Set fso1=nothing
End Function
End Class
在上传储存以后实例类
假设图片存入的地址变量为:imgurl
则调用类
set yulang=new imgInfo
w = yulang.imgW(server.mappath(imgurl))
h = yulang.imgH(server.mappath(imgurl))
set yulang=nothing
取得比例
flag=formatnumber(w/h,1)
存入数据库,OK了
下面是一个调用相似大小的子程序:
参数说明 (num 调用的个数)(w 载入时的宽度) (flag1 大于比例) (flag2 小于比例)
public sub pictvouchlist(num,w,flag1,flag2)
if num="" or w="" or flag1="" or flag2="" then exit sub
sql="select top "&num&" id,imgurl from myimg where flag>="&flag1&" and flag<="&flag2&""
set rs=conn.execute(sql)
if rs.bof and rs.eof then
response.Write("暂无合适的图片")
else
img=rs(1)
.....自己去写吧,呵呵
end sub
好了就写到这里。大家看到了
如果把比例存入数据库
只用一个过程。就可以在页面上随意摆放大小合适的图片了
ret(0)="JPG"
ret(2)=binval2(aso.Read(2))
ret(1)=binval2(aso.Read(2))
case else:
if left(Bin2Str(bFlag),2)="BM" then
aso.Read(15)
ret(0)="BMP"
ret(1)=binval(aso.Read(4))
ret(2)=binval(aso.Read(4))
else
ret(0)=""
end if
end select
ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""
getimagesize=ret
End Function
Public Function imgW(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
If (fso1.FileExists(pic_path)) Then
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
imgW = arr(1)
end select
Set f1=nothing
else
imgW = 0
End if
Set fso1=nothing
End Function
Public Function imgH(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
If (fso1.FileExists(pic_path)) Then
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
imgH = arr(2)
end select
Set f1=nothing
else
imgH = 0
End if
Set fso1=nothing
End Function
End Class
在上传储存以后实例类
假设图片存入的地址变量为:imgurl
则调用类
set yulang=new imgInfo
w = yulang.imgW(server.mappath(imgurl))
h = yulang.imgH(server.mappath(imgurl))
set yulang=nothing
取得比例
flag=formatnumber(w/h,1)
存入数据库,OK了
下面是一个调用相似大小的子程序:
参数说明 (num 调用的个数)(w 载入时的宽度) (flag1 大于比例) (flag2 小于比例)
public sub pictvouchlist(num,w,flag1,flag2)
if num="" or w="" or flag1="" or flag2="" then exit sub
sql="select top "&num&" id,imgurl from myimg where flag>="&flag1&" and flag<="&flag2&""
set rs=conn.execute(sql)
if rs.bof and rs.eof then
response.Write("暂无合适的图片")
else
img=rs(1)
.....自己去写吧,呵呵
end sub
好了就写到这里。大家看到了
如果把比例存入数据库
只用一个过程。就可以在页面上随意摆放大小合适的图片了
| 对此文章发表了评论 |
