Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap createThumbnail(String filePath, int newWidth, int newHeight) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(filePath, options); int originalWidth = options.outWidth; int originalHeight = options.outHeight; int ratioWidth = originalWidth / newWidth; int ratioHeight = originalHeight / newHeight; options.inSampleSize = ratioHeight > ratioWidth ? ratioHeight : ratioWidth; options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(filePath, options); } }