# Resizing Images - PLEASE HELP!

**URL:** <https://forum.kirupa.com/t/resizing-images-please-help/182755>\
**Category:** flash\
**Created:** [March 21, 2006, 7:30am UTC](https://forum.kirupa.com/t/resizing-images-please-help/182755 "2006-03-21T07:30:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickf828](https://avatars.discourse-cdn.com/v4/letter/n/5daacb/32.png) [@nickf828](https://forum.kirupa.com/u/nickf828)\
**Post date:** [March 21, 2006, 7:30am UTC](https://forum.kirupa.com/t/resizing-images-please-help/182755/1 "2006-03-21T07:30:08Z")

</div>

Hi, I am having issues getting an imagine to resize. I used the Kirupa XML photogallery tutorial, which works fine, but want the images to resize to fit in the square space I have on my site. I am loading images into a movie clip holder, and that all works fine, but I want to get the images to automatically resize, so they are constrained by both a max width and height, but stay proportional. So, if the max was 300 in both directions, a landscape shot would display with a width of 300 and a proportional height, and a portrait shot would be height of 300 and whatever the corresponding width was. The code I have in the movie clip now is below. It sort of works, but not all the time and something is a little off with the calculations. I’ve spent an embarassing amount of time on this but I am missing something. Also note I don’t want the images to change if they are smaller than the space, bc right now flash expands them. Thanks SO SO much for your help.

onClipEvent (load) {  
if (this.\_width\>this.\_height) {  
w\_target = 320/this.\_width;  
setProperty("", \_width, this.\_width_w\_target);  
setProperty("", \_height, this.\_height_w\_target);

} else {  
h\_target = 260/this.\_height;  
setProperty("", \_height, \_height_h\_target);  
setProperty("", \_width, this.\_width_h\_target);  
}}

PS - does anyone know a way to make the picture and/or movie clip holding it display centered?

PPS - I have also tried this…

onClipEvent (load) {  
if (this.\_width\>this.height && this.\_width\>300) {  
percentage = 320/this.\_width;  
setProperty("", \_width, this.\_width_percentage);  
setProperty("", \_height, this.\_height_percentage);

```
   } else if (this._height&gt;this.width && this.height&gt;200) { 
           percentage = 240/this._height; 
           setProperty("", _height,_height*percentage); 
           setProperty("", _width, this._width*percentage); 

```

} }
