Định kích thước ảnh bằng ASP

Published by admin on

<%
dim iWidth, iHeight, iType
sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject(“Scripting.FileSystemObject”)
if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
iType = myImg.Type
select case iType
case 0
iType = “None”
case 1
iType = “Bitmap”
case 2
iType = “Metafile”
case 3
iType = “Icon”
case 4
iType = “Win32-enhanced metafile”
end select
set myImg = nothing
end sub

ImgDimension(Server.MapPath(“../.”) & “imagesheader.gif”)

response.write(“Dimensions: ” & iWidth & ” x ” & iHeight & “
“)
response.write(“Image Type: ” & iType & “
“)
%>