I am trying to convert and compress an image taken from a filepath on android to be converted with base64's gzip (i am using this because my desktop version, written in java, is doing the same). Here is what I have currently for compression:
Bitmap bm = BitmapFactory.decodeFile(imagePath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] data = baos.toByteArray();
String base64Str = null;
ByteArrayOutputStream out_bytes = new ByteArrayOutputStream();
OutputStream out = new Base64.OutputStream(out_bytes);
try {
out.write(data);
out.close();
byte[] encoded = out_bytes.toByteArray();
base64Str = Base64.encodeBytes(encoded, Base64.GZIP);
baos.close();
} catch (Exception e) {}