본문 바로가기

프로그램&DB/ASP

[ASP DEXT] 이미지 썸네일(리사이즈)

Set UpLoad           = Server.CreateObject("DEXT.FileUpload")
set objImage         = Server.CreateObject("DEXT.ImageProc")
UPLOADPath         = UPLOADPath&"\tempFolder\"

.

.

.

 

'## 썸네일 사이즈가 고정이 아니라 비율로 줄어들게

ImageWidth = UpLoad("fileName").ImageWidth
ImageHeight = UpLoad("fileName").ImageHeight

 

fixWidth = 145    '## 썸네일 가로 사이즈
fixHeight = 110   '## 썸네일 세로 사이즈

if isThumbnail = "Y" then    '## 썸네일을 사용한다면
        if ImageWidth > fixWidth or ImageHeight > fixHeight then
            if ImageWidth > ImageHeight then
                resizeWidth = fixWidth
                resizeHeight = ImageHeight * fixWidth / ImageWidth
                if resizeHeight > fixHeight then
                    resizeWidth = fixHeight * ImageWidth / ImageHeight
                    resizeHeight = fixHeight
                end if
            else
                resizeHeight = fixHeight
                resizeWidth = ImageWidth * fixHeight / ImageHeight
                if resizeWidth > fixWidth then
                    resizeWidth = fixWidth
                    resizeHeight = fixWidth * ImageHeight / ImageWidth
                end if
            end if
        else
            resizeWidth = obj.width
            resizeHeight = obj.height
        end if


        If objImage.SetSourceFile(UPLOADPath&fileName) Then
            thumb_fileName = objImage.SaveAsThumbnail(UploadPath&"thumb\" &fileName , resizeWidth, resizeHeight, false)
        end if

end if