'이미지리사이즈'에 해당되는 글 2건

  1. 2010.01.28 이미지 리사이즈 스크립트 스케일 적용
  2. 2010.01.28 이미지 리사이즈 스크립트

function imgResize(i, maxW, maxH) {
 if(!maxW || !maxH ) {
  return;
 }
 var maxWidth = maxW;
 var maxHeight = maxH;
 
 var orgWidth = i.width;
 var orgHeight = i.height;

 var newWidth = orgWidth;
 var newHeight = orgHeight;

 var scaleWW = orgWidth/maxWidth;
 var scaleHH = orgHeight/maxHeight;

 // Determine the scale.
 if(orgWidth > maxWidth || (orgHeight > maxHeight && maxHeight > 0)){
  if(scaleWW > scaleHH || maxHeight == 0){
   newWidth = maxWidth;
   newHeight = Math.round(orgHeight/scaleWW);
  } else {
   newHeight = maxHeight;
   newWidth = Math.round(orgWidth/scaleHH);
  }
 }
 
 // 리사이즈한 크기로 이미지 크기 다시 지정
 i.width = newWidth;
 i.height = newHeight;
}

Posted by [czar]
,
function checkImages() {
 var imgs = document.getElementById("thisContents").getElementsByTagName("IMG");
 for (var i=0; i   if (imgs[i].width >= 820) {
   imgs[i].width="820";
  }
 }
}



// 이미지 리싸이즈 함수
//  인자는 최대 width
function changeImageSize(pWidth) {
    var r, re;
    testImg = new Image();
    
    re = /이미지폴더|이미지폴더/i;
    for (var i=0;i<document.images.length;i++) {

        r = (document.images[i].src).search(re);
        if (r > -1 && document.images[i].src != "") {
            testImg.src = document.images[i].src;
            if (testImg.width > pWidth) {
                document.images[i].width = pWidth;
                document.images[i].height = testImg.height * pWidth / testImg.width;
            }
        }
    }
}




Posted by [czar]
,