아는 것이 좋은 것이다.

[ASP] 이미지 리사이즈 본문

ASP

[ASP] 이미지 리사이즈

start0 2014. 4. 24. 21:54

 

'사용법 : Resize_Img(이미지경로, 가로최대, 세로최대)
Function Resize_Img(imgPath, maxWidth, maxHeight)
 
    Dim objImg
    Set objImg = LoadPicture(imgPath)
    Dim imgWidth  : imgWidth  = Cint(objImg.Width * 24 / 635)      '이미지 Width
    Dim imgHeight : imgHeight = Cint(objImg.Height * 24 / 635)     '이미지 Height
    Dim reWidth, reHeight
 
    If imgWidth > maxWidth Or imgHeight > maxHeight Then
        If imgWidth > imgHeight Then
           reWidth  = maxWidth
           reHeight = Int((imgHeight * reWidth) / imgWidth)
        Else
           reHeight = maxHeight
           reWidth  = Int((reHeight * imgWidth) / imgHeight)
        End If
    Else
        reWidth  = imgWidth
        reHeight = imgHeight
    End If

 

    Set objImg = Nothing

    Resize_Img = reWidth & "/" & reHeight

 

End Function


 

Comments