원본 이미지의 크기가 너무 클 때 일정 비율로 줄여서 호출하고 싶다면..
아래 스크립트를 사용해 보시길..
<script>
//이미지 리사이즈
function resizeImg(imgID){
imgWidth = eval("document." + imgID + ".width") ;
imgHeight = eval("document." + imgID + ".height") ;
maxWidth = 600 ;
maxHeight = 600 ;
if(imgWidth > maxWidth || imgHeight > maxHeight){
if(imgWidth > imgHeight){
reWidth = maxWidth;
reHeight = Math.round((imgHeight * reWidth) / imgWidth) ;
}else{
reHeight = maxHeight;
reWidth = Math.round((reHeight * imgWidth) / imgHeight) ;
}
}else{
reWidth = imgWidth ;
reHeight = imgHeight ;
}
eval("document." + imgID + ".width = " + reWidth) ;
eval("document." + imgID + ".height = " + reHeight) ;
}
</script>
- 호출
<img src="<%=imgPath%>" border="0" name="imgOrg" onload="resizeImg('imgOrg')">