title: Android : Take photo, store it on sdcard and overwrite it for creating smaller photo
body: <p>Here is my code which reproduce this scenario :</p>
  
  <ul>
  <li>The user click on "Take photo" button and take a picture</li>
  <li>The user click on "Create annonce" button, which upload the captured photo to the server.</li>
  </ul>
  
  <p><strong>All these parts works fine, but the problem that i would like to solve is that the size of uploaded image is so big : around 2Mo.</strong></p>
  
  <p>I would like to create a shadow copy of captured image for creating a smaller photo based on the first. (We can overwrite the first if it's possible).</p>
  
  <p>I don't know how to do this, and where to do this in my code ?</p>
  
  <p><strong>Code to initialize destination file :</strong></p>
  
  <pre><code>String uniqueID = UUID.randomUUID().toString();
          String name = dateToString(new Date(),"yyyy-MM-dd-hh-mm-ss");
          imageToStore = name + uniqueID + ".jpg";
          destination = new File(Environment.getExternalStorageDirectory(), imageToStore);
  </code></pre>
  
  <p><strong>When the user click on button, it start photo capture :</strong></p>
  
  <pre><code>takePhoto.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(destination));
                  startActivityForResult(intent, REQUEST_IMAGE);
  
                  overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
              }
          });
  </code></pre>
  
  <p><strong>Code to treat the capture :</strong></p>
  
  <pre><code>@Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          if( requestCode == REQUEST_IMAGE &amp;&amp; resultCode == Activity.RESULT_OK ){
              try {
                  preview.setVisibility(View.VISIBLE);
                  takePhoto.setVisibility(View.GONE);
                  txtHaut.setText("Cette image est parfaite !");
                  FileInputStream in = new FileInputStream(destination);
                  BitmapFactory.Options options = new BitmapFactory.Options();
                  options.inSampleSize = 8;
                  imagePath = destination.getAbsolutePath();
                  Log.d("INFO", "PATH === " +imagePath);
                  Bitmap bmp = BitmapFactory.decodeStream(in, null, options);
                  preview.setImageBitmap(bmp);
              } catch (FileNotFoundException e) {
                  e.printStackTrace();
              }
  
          }
          else{
              tvPath.setText("Request cancelled");
          }
      }
  </code></pre>
  
  <p><strong>And finally, when the user click on "Create annonce" button, it upload the photo :</strong></p>
  
  <pre><code>btnCreate.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  dialog = ProgressDialog.show(New_annonce_act_step3.this, "", "Création de votre annonce en cours ..", true);
  
                  new Thread(new Runnable() {
                      public void run() {       
                          uploadFile(imagePath);
                      }
                  }).start();
  
              }
  
          });
  </code></pre>