I need to resize an image(shrink) and maintain the aspect ratio. I have a constant new width 500px and of course I know how big it is to start with.
This is what I have. It works about 90% of the time. In fact it migrated 1000+ images. Total mb for images to start was 150mb after it is 36mb, and all the images look very good.
I know it's bad to do all that on one line. So far it blows up on images that are 1024x768 with a new height = 0. I don't know what the problem is other than the values being calculated when it craps out are like 0.4567 and the it just goes bad. It took me a week to find this way that almost works all the time... somebody please help.Code:int nHeight = ((int)( 100 * (int)System.Math.Round(((decimal)500)/((decimal)bmp.Width)) * bmp.Height) / 100);




Reply With Quote