Java tutorial
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static void compressIt(String inputFile, String outputFile) { try { Bitmap bmp = BitmapFactory.decodeFile(inputFile); FileOutputStream out = new FileOutputStream(new File(outputFile)); bmp.compress(Bitmap.CompressFormat.PNG, 50, out); //100-best quality out.close(); } catch (Exception e) { e.printStackTrace(); } } }