ImageProp

Methods

 

 

setHeight

변경할 이미지 높이를 설정합니다.

 

Syntax

    void setHeight ( int height )

Parameters

height

[in] 변경할 이미지 높이를 입력합니다. 기본 값은 원본 이미지의 높이입니다.

 

Return Values

 

Remarks

 

Sample Codes

Java

FileUpload fileUpload = new FileUpload(request, response); 
try { 
	fileUpload.setAutoMakeDirs(true);

	String saveDirPath = request.getRealPath("/");
	saveDirPath += ("UploadDir" + File.separator);
	fileUpload.startUpload(saveDirPath); 	

	FileItem fileItem = fileUpload.getFileItem("files");

	if(fileItem != null) { 
		fileItem.save(saveDirPath); 	
		
		ImageTool image = ImageTool.getImage(fileItem);
		if(image != null) { 
			image.setAutoMakeDirs(true); 
			String imageSaveDirPath = saveDirPath + "image" + File.separator; 
			
			/**
			* [ 이미지 변경을 위한 ImageProp 객체의 프로퍼티] 
			* setWidth : 생성할 이미지의 너비를 설정합니다. 기본 값은 원본 이미지의 너비입니다. 
			* setHeight : 생성할 이미지의 높이를 설정합니다. 기본 값은 원본 이미지의 높이입니다.
			* setRatio : 변경할 원본 이미지의 비율입니다. 비율에 따라 너비와 높이가 설정됩니다. 기본 값은 원본 이미지의 비율입니다.
			* 			 원본 크기 비율은 1.0f입니다. (예, 2.0f는 두배 크기, 0.5f는 원본의 1/2일 크기) 
			*			 너비, 높이를 명시적으로 입력하면 비율은 무시됩니다. 
			* setQuality : 생성할 이미지의 퀄리티를 설정합니다. 기본 값은 1.0f이며, 가장 높은 퀄리티입니다. 
			* setFormatName : 생성할 이미지의 포맷 설정합니다. 기본 값은 원본 이미지의 포맷입니다. 
			*				: 지원되지 않는 포맷 이름을 입력할 경우 예외가 발생합니다. 
			*/
			// 비율로 변경할 이미지 크기 변경 
			ImageProp imageProp = new ImageProp(); 
			imageProp.setRatio(0.5f); // 원본의 50% 비율 
			String ratioFilePath = image.convert(imageProp, imageSaveDirPath);  
			
			// 너비, 높이 지정으로 이미지 크기 변경
			imageProp.setWidth(100);
			imageProp.setHeight(100);
			String fixedFilePath = image.convert(imageProp, imageSaveDirPath);  
		}
	}
}
catch(CrossUploaderException ex) { 
}
catch(Exception ex) { 
	fileUpload.deleteUploadedFiles(); 
}
finally { 
	fileUpload.clear(); 
}