Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] compress(Bitmap bitmap, int persentage) { if (bitmap == null) return new byte[0]; if (persentage <= 0) persentage = 0; else if (persentage > 100) persentage = 100; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, persentage, baos); return baos.toByteArray(); } }