title: Resize image while keeping aspect ratio in Java
body: <p>im trying to resize bufferdImage in memory in java but to keep the aspect ratio of the image 
  im have something like this but this is not good </p>
  
  <pre><code>int w = picture.getWidth();
  int h = picture.getWidth();
  int neww=w;
  int newh=h;
  int wfactor = w;
  int hfactor = h;
  if(w &gt; DEFULT_PICTURE_WIDTH || h &gt; DEFULT_PICTURE_HIGHT)
  {
      while(neww &gt; DEFULT_PICTURE_WIDTH)
      {
          neww = wfactor /2;
          newh = hfactor /2;
          wfactor = neww;
          hfactor = newh;
      }
  }
  
  picture = Utils.resizePicture(picture,neww,newh);
  </code></pre>