# Resizing & Scaling an Image

**URL:** <https://forum.kirupa.com/t/resizing-scaling-an-image/19235>\
**Category:** flash\
**Created:** [April 25, 2003, 4:29pm UTC](https://forum.kirupa.com/t/resizing-scaling-an-image/19235 "2003-04-25T16:29:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![7of9](https://avatars.discourse-cdn.com/v4/letter/7/c89c15/32.png) [@7of9](https://forum.kirupa.com/u/7of9)\
**Post date:** [April 25, 2003, 4:29pm UTC](https://forum.kirupa.com/t/resizing-scaling-an-image/19235/1 "2003-04-25T16:29:22Z")

</div>

One of the members wrote a function that sizes an image onto a movieclip and it works great. But only if the images are the same size. I want to be able to import any size image and scale if necessary and resize the image into my movieclip. Can anyone help me?

\_global.resizeImage= function()  
{  
//maximum image dimensions  
//Note: The images have to be the same size  
//so they can be scaled the same.  
wMax = 292; //42  
hMax = 359; //109

```
if(img_mc._width &gt; wMax || img_mc._height &gt; hMax) 
 {
	//which dimension is the most oversized
	wDiff = img_mc._width - wMax;
	hDiff = img_mc._height - hMax;
	//calculate ratio
	if(wDiff &gt; hDiff) 
	 {
	   ratio = (wMax/img_mc._width) * 100;
	 } 
	else 
	 {
	   ratio = (hMax/img_mc._height) * 100;
	 }
 } 
else 
 {
   //if image doesn't need to be resized set ratio to 100
   ratio = 100;	
 }
img_mc._xscale = img_mc._yscale = ratio;	

```

};
