이미지 파일 저장 및 썸네일 이미지를 생성하는 방법입니다.


간단한 예제

FilePath = 실제 파일 저장 경로
FilePath__ = 썸네일 이미지 파일 저장 경로
IntWidth = 썸네일 이미지 최대 가로 크기
IntHeight = 썸네일 이미지 최대 세로 크기
ImageWidth = 이미지 가로 크기 / 썸네일 이미지 가로 크기
ImageHeight = 이미지 세로 크기 / 썸네일 이미지 세로 크기

<%

Dim FSO, FilePath, FilePath__

FilePath     = Server.MapPath("/photo") & "\"

FilePath__   = Server.MapPath("/photo/thumb") & "\"


'== 실제경로 폴더의 존재여부 판단

Set FSO = Server.CreateObject("Scripting.FileSystemObject")


If Not FSO.FolderExists(FilePath) Then

FSO.CreateFolder(FilePath)

End if


If Not FSO.FolderExists(FilePath__) Then

FSO.CreateFolder(FilePath__)

End If


Set FSO = Nothing


Set UF = Server.CreateObject("Dext.FileUpload")

UF.DefaultPath = Server.MapPath("/photo") & "\"

UF.UploadTimeout = 1200             ' 업로드 Timeout 설정

UF.MaxFileLen = int(1024 * 1024 * 10) ' 하나의 파일 크기를 10MB 이하로 제한


'== 썸네일 이미지 생성

Dim objimg, ImageWidth, ImageHeight

Dim intWidth : intWidth = 150

Dim intHeight : intHeight = 150

Set objImg = Server.CreateObject("DEXT.ImageProc")


ImageWidth      = UF.Form("upfile").ImageWidth

 ImageHeight      = UF.Form("upfile").ImageHeight


   Do While ImageWidth > IntWidth And ImageHeight > IntHeight ' Do While 문을 이용하여 이미지 사이즈 재설정

       ImageWidth = ImageWidth / 1.2

 ImageHeight = ImageHeight / 1.2

  Loop


If objImg.SetSourceFile(FilePath & MAIN_IMG_NAME) Then 

FileUpload = objImg.SaveAsThumbnail( FilePath__ & UF.Form("upfile") , ImageWidth, ImageHeight, True ) 

End If


Set objImg = Nothing


Set UF = Nothing


%>


+ Recent posts