# A different image resize question

**URL:** <https://forum.kirupa.com/t/a-different-image-resize-question/140426>\
**Category:** Uncategorized\
**Created:** [March 10, 2005, 9:57pm UTC](https://forum.kirupa.com/t/a-different-image-resize-question/140426 "2005-03-10T21:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![2nd\_day](https://avatars.discourse-cdn.com/v4/letter/2/a4c791/32.png) [@2nd\_day](https://forum.kirupa.com/u/2nd_day)\
**Post date:** [March 10, 2005, 9:57pm UTC](https://forum.kirupa.com/t/a-different-image-resize-question/140426/1 "2005-03-10T21:57:51Z")

</div>

this is my code:

```auto

function resizepic() {
	container._alpha = 0;
	totalw = container._width;
	totalh = container._height;
	maxw = 378;
	maxh = 284;
	if (totalw>totalh) {
		factorw = (maxw/totalw);
		container._width = maxw;
		container._height = factorw*totalh;
		container._x = _root.xpos+(((maxw)-container._width)/2);
		container._y = _root.ypos+(((maxh)-container._height)/2);
	}
	if (totalh>totalb) {
		factorh = (maxh/container._height);
		container._height = maxh;
		container._width = factorh*totalw;
		container._x = _root.xpos+(((maxw)-container._width)/2);
		container._y = _root.ypos+(((maxh)-container._height)/2);
	}
	container._alpha = 100;
}

```

but the problem is that when a pic is 400 \* 398 you get this:  
totalw\>totalh (400\>398)  
factorw = 378/400 = 0.945  
container.\_width = 378  
container.\_height = 0.945\*398 = 376.11

as you see the container.\_height is bigger than the maxh (maximum height) but the \_width is just fine… how do i fix this problem??

thanks for helping 😃
