如何取得图片的长和宽啊?

mygia 2003-10-18 03:45:22
如题!
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mygia 2003-10-18
  • 打赏
  • 举报
回复
谢谢各位。结帐!1
avonqin 2003-10-18
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2359/2359445.xml?temp=.4350855
http://expert.csdn.net/Expert/topic/2196/2196462.xml?temp=.4070703

不知有没有你要的
nchen123 2003-10-18
  • 打赏
  • 举报
回复
<%
Class possible
dim aso
Private Sub Class_Initialize
set aso=CreateObject("Adodb.Stream")
aso.Mode=3
aso.Type=1
aso.Open
End Sub
Private Sub Class_Terminate
set aso=nothing
End Sub

Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if ASCB(clow)<128 then
Str = Str & Chr(ASCB(clow))
else
I=I+1
if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
end if
Next
Bin2Str = Str
End Function

Private Function Num2Str(num,base,lens)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) & ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") & num & ret,lens)
End Function

Private Function Str2Num(str,base)
dim ret
ret = 0
for i=1 to len(str)
ret = ret *base + cint(mid(str,i,1))
next
Str2Num=ret
End Function

Private Function BinVal(bin)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function

Private Function BinVal2(bin)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function

Private Function getImageSize(filespec)
dim ret(3)
aso.LoadFromFile(filespec)
bFlag=aso.read(3)
select case hex(binVal(bFlag))
case "4E5089":
aso.read(15)
ret(0)="PNG"
ret(1)=BinVal2(aso.read(2))
aso.read(2)
ret(2)=BinVal2(aso.read(2))
case "464947":
aso.read(3)
ret(0)="GIF"
ret(1)=BinVal(aso.read(2))
ret(2)=BinVal(aso.read(2))
case "535746":
aso.read(5)
binData=aso.Read(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
while(len(sConv)<nBits*4)
binData=aso.Read(1)
sConv=sConv&Num2Str(ascb(binData),2 ,8)
wend
ret(0)="SWF"
ret(1)=int(abs(Str2Num(mid(sConv,1*nBits+1,nBits),2)-Str2Num(mid(sConv,0*nBits+1,nBits),2))/20)
ret(2)=int(abs(Str2Num(mid(sConv,3*nBits+1,nBits),2)-Str2Num(mid(sConv,2*nBits+1,nBits),2))/20)
case "FFD8FF":
do
do: p1=binVal(aso.Read(1)): loop while p1=255 and not aso.EOS
if p1>191 and p1<196 then exit do else aso.read(binval2(aso.Read(2))-2)
do:p1=binVal(aso.Read(1)):loop while p1<255 and not aso.EOS
loop while true
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

Function readX(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
Response.Write arr(1)
case "swf"
arr=pp.getimagesize(f1.path)
Response.Write arr(1)
end select
Set f1=nothing
Set fso1=nothing
End Function

Function readY(pic_path)
Set fso1 = server.CreateObject("Scripting.FileSystemObject")
Set f1 = fso1.GetFile(pic_path)
ext=fso1.GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1.path)
Response.Write arr(2)
case "swf"
arr=pp.getimagesize(f1.path)
Response.Write arr(2)
end select
Set f1=nothing
Set fso1=nothing
End Function
End Class
%>

例子:

<!--#include file="picXY.asp"-->
<%
set pp=new possible
pp.readX("E:\work\bg.jpg")
pp.readY("E:\work\bg.jpg")
%>
xxu333 2003-10-18
  • 打赏
  • 举报
回复

ASPUPload组件
<%

Set Upload = Server.CreateObject("Persits.Upload")

' Use AspJpeg to resize image
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Capture and save uploaded image to the same directory as script
Upload.Save Server.MapPath(".")

For Each File in Upload.Files
If File.ImageType <> "JPG" Then
Response.Write "This is now a JPGE image."
File.Delete
Response.End
End If

Jpeg.Open File.Path

Scale = Upload.Form("Scale")
Jpeg.Width = Jpeg.OriginalWidth * Scale / 100
Jpeg.Height = Jpeg.OriginalHeight * Scale / 100

Response.Write Jpeg.OriginalHeight & "-" & Jpeg.Height

Jpeg.Save Server.MapPath(".") & "\small_" & File.FileName
%>
<IMG SRC="<% = File.FileName %>"><BR>
<IMG SRC="<% = "small_" & File.FileName %>"><P>
<%
Next
%>
mygia 2003-10-18
  • 打赏
  • 举报
回复
免费的都是有限制的。比如只能切割成多大啊。我想不用组件的。就像无组件上传那样!
pjchuqi 2003-10-18
  • 打赏
  • 举报
回复
有免费的图片组件可以实现,你可以去搜索一下!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧