# Scaling & Resizing an Image on a Mc

**URL:** <https://forum.kirupa.com/t/scaling-resizing-an-image-on-a-mc/19294>\
**Category:** flash\
**Created:** [April 26, 2003, 5:01am UTC](https://forum.kirupa.com/t/scaling-resizing-an-image-on-a-mc/19294 "2003-04-26T05:01:57Z")\
**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 26, 2003, 5:01am UTC](https://forum.kirupa.com/t/scaling-resizing-an-image-on-a-mc/19294/1 "2003-04-26T05:01:57Z")

</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 \> wMax || img\_mc.\_height \> hMax)  
{  
//which dimension is the most oversized  
wDiff = img\_mc.\_width - wMax;  
hDiff = img\_mc.\_height - hMax;  
//calculate ratio  
if(wDiff \> 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;  
};
