title: How to compress multiple images size to particular(100kb) size in android?
body: <p>I am new to android. I want to reduce the size of a bitmap to 100kb exactly. I get an image from the sdcard, compress it and save it to the sdcard again with a different name into a different directory. Compression works fine (3 mb like image is compressed to around 100 kb). I trying to compress 1mb image to 100kb, but i am getting size of that image is 20kb. But i need that 1mb(or 2mb (or) 3mb (or) 4mb (or) 5mb.....) image also get resize to 100kb. and my code is,,</p>
  
  <p>private Bitmap getResizedBitmap(Bitmap bm, int maxSize)
          {
              int width = bm.getWidth();
              int height = bm.getHeight();</p>
  
  <pre><code>        float bitmapRatio = (float)width / (float) height;
          if (bitmapRatio &gt; 0) {
              width = maxSize;
              height = (int) (width / bitmapRatio);
          } else {
              height = maxSize;
              width = (int) (height * bitmapRatio);
          }
          return Bitmap.createScaledBitmap(bm, width, height, true);
      }
  </code></pre>