title: Android, Java, Creating a thumbnail keeping aspect ratio
body: <p>I'm trying to create a thumbnail of a certain height but maintain the aspect ratio. I'm using the code below but the problem arises when say if an image is somewhat small the image generated will not fill the thumbnail area. imageURI is just the path to the image.</p>
  
  <pre><code>            BitmapFactory.Options o = new BitmapFactory.Options();
              o.inJustDecodeBounds = true;
              BitmapFactory.decodeFile(imageURI, o);
              final int REQUIRED_SIZE=70;
  
              int width_tmp=o.outWidth, height_tmp=o.outHeight;
              int scale=4;
              while(true){
                  if(width_tmp/2&lt;REQUIRED_SIZE || height_tmp/2&lt;REQUIRED_SIZE)
                      break;
                  width_tmp/=2;
                  height_tmp/=2;
                  scale++;
              }
  
              BitmapFactory.Options o2 = new BitmapFactory.Options();
              o2.inSampleSize=scale;   
              Bitmap bitmap = BitmapFactory.decodeFile(imageURI, o2);
  </code></pre>