Try following code, you might need to modify some of the parameters as per your requirement : 
Create MainActivity as following :
public class MainActivity extends Activity implements OnClickListener {
private final int REQUEST_IMAGE_GALLERY = 2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.button).setOnClickListener(this);
}
@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.button:
        pickImageFromGallery();
        break;
    default:
        break;
    }
}
private void pickImageFromGallery() {
    Intent intent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "Select File"),
            REQUEST_IMAGE_GALLERY);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != Activity.RESULT_OK) {
        return;
    }
    if (requestCode == REQUEST_IMAGE_GALLERY) {
        Uri selectedImageUri = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };
        Cursor cursor = getContentResolver().query(selectedImageUri,
                filePathColumn, null, null, null);
        cursor.moveToFirst();
        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String picturePath = cursor.getString(columnIndex);
        cursor.close();
        Log.e("PATH", "" + picturePath);
        Intent intent = new Intent(this, AddImage.class);
        intent.putExtra("PATH", picturePath);
        startActivity(intent);
    }
}
}
Now create activity_main.xml as follows :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
    android:id="@+id/button"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ChooseButton" />
    </LinearLayout>
Then we need to create AddImage activity as follows :
public class AddImage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_image);
    ImageView imageView = (ImageView) findViewById(R.id.image_view);
    if (getIntent() != null) {
        String path = getIntent().getStringExtra("PATH");
        Log.e("PATHR", "" + path);
        new BitmapWorkerTask(imageView).execute(path);
    }
}
private boolean isNeedToBeScaled(String path) {
    File file = new File(path);
    if (file.length() > (1024 * 1024) && isExist(path)) {
        Log.e("SCALEIMAGE", "SACLE");
        return true;
    }
    return false;
}
private boolean isExist(String path) {
    File file = new File(path);
    return file.exists();
}
private Bitmap getScaledImage(String path) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(path, options);
    int srcWidth = options.outWidth;
    int srcHeight = options.outHeight;
    int[] newWH = new int[2];
    newWH[0] = srcWidth / 2;
    newWH[1] = (newWH[0] * srcHeight) / srcWidth;
    int inSampleSize = 2;
    while (srcWidth / 2 >= newWH[0]) {
        srcWidth /= 2;
        srcHeight /= 2;
        inSampleSize *= 2;
        options.inJustDecodeBounds = false;
        options.inDither = false;
        options.inSampleSize = inSampleSize;
        options.inScaled = false;
        options.inPreferredConfig = Bitmap.Config.RGB_565;
    }
    Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(path, options);
    return sampledSrcBitmap;
}
class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
    private final WeakReference<ImageView> imageViewReference;
    public BitmapWorkerTask(ImageView mImageView) {
        imageViewReference = new WeakReference<ImageView>(mImageView);
    }
    @Override
    protected Bitmap doInBackground(String... params) {
        Bitmap scaled = null;
        if (isNeedToBeScaled(params[0])) {
            Bitmap d;
            d = getScaledImage(params[0]);
            int nh = (int) (d.getHeight() * (512.0 / d.getWidth()));
            scaled = Bitmap.createScaledBitmap(d, 512, nh, true);
        } else {
            scaled = BitmapFactory.decodeFile(params[0], null);
        }
        return scaled;
    }
    @Override
    protected void onPostExecute(Bitmap result) {
        if (imageViewReference != null && result != null) {
            final ImageView imageView = imageViewReference.get();
            if (imageView != null) {
                imageView.setImageBitmap(result);
                imageView.setVisibility(View.VISIBLE);
            }
        }
    }
}
}