Image Size 1

This example dynamically changes the size of the image to 75% of its default size.

The image at its default size.

If you set the img tags width and height property to 75% this will show the image at 75% of the window size.

The following uses the image object to resize the image to 75% of its default size.

<script type="text/javascript"> 

function changImgSize(imgObj){
newObj= new Image()
newObj.src=imgObj.src

// if you only resize one dimension, width or height, the other will resize by the same %
// using both the following lines allows the height to be resized by a different % to the width

imgObj.style.width=newObj.width*0.75
imgObj.style.height=newObj.height*0.75

}

</script>

<img src="pic.jpg" onload="changImgSize(this)">

The following example shows how you can display your images the same size irrespective of the default image size

Image 1 Image 2 Image 3 Image 4 Image 5





The following example shows how you can change the images size irrespective of the default images size

Image 1 Image 2 Image 3 Image 4 Image 5





<img src="" name="pic1">

myImage=new Image(170,70)
myImage.src="pic01.jpg"
document.images["pic1"].width=myImage.width
document.images["pic1"].height=myImage.height
document.images["pic1"].src=myImage.src