Here you can find the source of smallPic(String oldPath, String newPath, int size)
public static File smallPic(String oldPath, String newPath, int size)
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static File smallPic(String oldPath, String newPath, int size) { BitmapFactory.Options opts = new BitmapFactory.Options(); Bitmap resizeBmp;/*ww w. ja v a 2 s . com*/ opts.inSampleSize = size; opts.inJustDecodeBounds = false; resizeBmp = BitmapFactory.decodeFile(oldPath, opts); File pictureFile = new File(newPath); try { if (pictureFile.exists()) { pictureFile.delete(); } pictureFile.createNewFile(); FileOutputStream fOut = new FileOutputStream(pictureFile); resizeBmp.compress(Bitmap.CompressFormat.JPEG, 50, fOut); fOut.flush(); fOut.close(); } catch (Exception e) { e.printStackTrace(); return null; } if (resizeBmp.isRecycled() == false) { resizeBmp.recycle(); System.gc(); } return pictureFile; } }