title: android encode image with max size limit
body: <p>I need to encode an image to be JPEG and maximum file zise to be 300 K and send it as byte array. I make encoding :</p>
  
  <pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
  image = baos.toByteArray();
  </code></pre>
  
  <p>do you know how to limit the file size to 300K? maybe the solution is to make image quality lower, but sometimes(when the image is smaller) I may not need this. Thanks</p>