# Image resize issue

**URL:** https://forum.kirupa.com/t/image-resize-issue/179207
**Category:** Uncategorized
**Created:** [February 17, 2006, 4:52pm UTC](https://forum.kirupa.com/t/image-resize-issue/179207 "2006-02-17T16:52:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tanel96](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tanel96](https://forum.kirupa.com/u/tanel96)
#### Post date: [February 17, 2006, 4:52pm UTC](https://forum.kirupa.com/t/image-resize-issue/179207/1 "2006-02-17T16:52:35Z")

</div>

```auto

max_height = 500;
max_width = 500;
_root.picture.loadMovie("http://fritz.msn.ee/album/audes105/pilt2.jpg");
function size() {
 if (picture._width>picture._height and picture._width>max_width) {
  picture._height = Math.floor(max_height*picture._height/picture._width);
  picture._width = max_width;
 } else if (picture._height>picture._width and picture._height>max_height) {
  picture._width = Math.floor(max_height*picture._width/picture._height);
  picture._height = max_height;
 }
}
this.onEnterFrame = function() {
 total = picture.getBytesTotal();
 loaded = picture.getBytesLoaded();
 if (loaded == total && loaded>4) {
  size();
 }
};
button.onRelease = function() {
 _root.picture.loadMovie("http://fritz.msn.ee/album/audes105/pilt3.jpg");
};
 

```

It’s a small part form a bigger script. The prblem is:

it resizes the first picture perfectly, but after i click the button, the new image comes out waay too small, i cant find the error anywhere ☹

pilt2 is 1952_2608  
pilt3 is 500_375
