티스토리 뷰
http://www.alexandru.es/blog/tag.php?tag=scripting
단계 1 : 다운받고 설치
여기서 다운받고 설치, 설치중 "Install ImageMagickObject OLE Control for VBscript, Visual Basic, and WSH"를 꼭 체크하고 설치.
단계 2: 스크립트 다운받거나 복사
다음의 코드를 imageResizer.vbs 복사후 새파일로 저장하든가 그냥 여기서 다운받기.
Copy imageResizer.vbs into a folder full of images and double-click it, it will then create a folder named "_thumbs" and store there all the resized images. You're done!
ASP 웹사이트에서 크기조정 하는법
resizeImage 함수 있는 줄 다음 부분을 수정해야 함:
다음을:
resizeImage("C:\Inetput\wwwroot\mywebsite\images\test.jpg", 640, 480, "C:\Inetput\wwwroot\mywebsite\images\test_resized.jpg")
단계 1 : 다운받고 설치
여기서 다운받고 설치, 설치중 "Install ImageMagickObject OLE Control for VBscript, Visual Basic, and WSH"를 꼭 체크하고 설치.
단계 2: 스크립트 다운받거나 복사
다음의 코드를 imageResizer.vbs 복사후 새파일로 저장하든가 그냥 여기서 다운받기.
Option Explicit
' 몇몇 변수 정의
Dim objFSO, folderSRC, pathSourceJPG, file, outputFolder
Dim userHeight, userWidth, userConfirmation
userWidth = InputBox("Please enter new width for the images:", "imageResizer.vbs", "640")
userHeight = InputBox("Please enter new height for the images:", "imageResizer.vbs", "480")
' 사용자가 입력한 넓이와 높이가 있는지 검사
if len(userHeight) = 0 or len(userWidth) = 0 then
wscript.echo "Missing parameter, width or height, quitting."
wscript.quit
end if
' 계속하기 전 사용자 확인
userConfirmation = MsgBox("Resize all images in the folder to "& userWidth & "x" & userHeight&"?", 1, "imageResizer.vbs")
if userConfirmation <> 1 then
wscript.echo "Script was canceled, quitting."
wscript.quit
end if
Set objFSO = createobject("Scripting.FileSystemObject")
pathSourceJPG = objFSO.GetAbsolutePathName(".\")
outputFolder = pathSourceJPG & "\_thumbs\"
Set folderSRC = objFSO.GetFolder(pathSourceJPG)
' 결과폴더 생성
if objFSO.FolderExists(outputFolder) then
wscript.echo "Output folder """ & outputFolder & """ already exists, I'm going to continue anyway."
else
objFSO.CreateFolder(outputFolder)
end if
' 파일 브라우징
For each file in folderSRC.Files
' Check for extensions
Dim fileExt
fileExt = lcase(objFSO.GetExtensionName(pathSourceJPG &"\"& file.Name))
If fileExt = "jpg" or fileExt = "jpeg" or fileExt = "gif" or fileExt = "png" or fileExt = "bmp" Then
' Run the resize function
resizeImage pathSourceJPG &"\"& file.Name, userWidth, userHeight, outputFolder & file.Name
end if
next
set folderSRC = nothing
'--------------------------
' resizeImage(input image, new height, new width, output image)
'--------------------------
function resizeImage(sourceFile, toWidth, toHeight, destinationFile)
Dim imgWidth, imgHeight, img
Dim xScale, yScale
Dim newWidth, newHeight
Dim conversion
' Load ImageMagick
Set img = CreateObject("ImageMagickObject.MagickImage.1")
' Get current image size
imgWidth = img.Identify ("-format", "%w", sourceFile)
imgHeight = img.Identify ("-format", "%h", sourceFile)
' Calculate scale
xScale = imgWidth / toWidth
yScale = imgHeight / toHeight
' Calculate new width and height
if yScale > xScale then
newWidth = round(imgWidth * (1/yScale))
newHeight = round(imgHeight * (1/yScale))
else
newWidth = round(imgWidth * (1/xScale))
newHeight = round(imgHeight * (1/xScale))
end if
' Run Convert to resize the image.
conversion = img.Convert("-resize", newWidth&"x"&newHeight&"!", sourceFile, destinationFile)
set conversion = nothing
end function
Step 3: 이미지 있는곳에 스크립트파일 넣고 실행!Copy imageResizer.vbs into a folder full of images and double-click it, it will then create a folder named "_thumbs" and store there all the resized images. You're done!
ASP 웹사이트에서 크기조정 하는법
resizeImage 함수 있는 줄 다음 부분을 수정해야 함:
다음을:
Set img = CreateObject("ImageMagickObject.MagickImage.1")
이렇게: Set img = Server.CreateObject("ImageMagickObject.MagickImage.1")ASP 페이지 안 함수에 복사하여 붙이고, 다음과 같이 실행:resizeImage("C:\Inetput\wwwroot\mywebsite\images\test.jpg", 640, 480, "C:\Inetput\wwwroot\mywebsite\images\test_resized.jpg")
'웹프로그래밍 > ASP Classic' 카테고리의 다른 글
| [Classic ASP] 변수 형식 알기 (0) | 2010.12.27 |
|---|---|
| Classic ASP로 네이트 인증 (Dev.Square 네이트 인증 API) (0) | 2010.12.21 |
| ASP 자체 Binary 이미지 나타내기 (0) | 2010.11.23 |
| [Classic ASP] pixlr API 활용법 (0) | 2010.11.23 |
| [Classic ASP] 네이버LAB 포토에디터 API 활용예제 (0) | 2010.11.23 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Debug
- ASP
- iphone
- PHP
- JSON
- javascript
- nginx
- Docker
- git
- Mac
- CSS
- classic asp
- macos
- Android
- 안드로이드
- centos
- Linux
- laravel
- API
- JQuery
- IE
- mssql
- Wordpress
- sencha touch
- Prototype
- 워드프레스
- iis
- 한글
- IOS
- nodejs
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함