title: Take image from gallery and convert to base64 issue
body: <p>sorry for asking silly question.but it solved yet my me.please help i had tried all codes on stackoverflow and follow other tutorial but it wont help at all.i am taking image from galary and convert to base64 it works perfectly fine when taking image on camera but why it dont work on galary i dont know please help me.;(</p>
  
  <p>This is the code to select the image</p>
  
  <pre><code>private void selectImage() {
          final CharSequence[] items = { "Take Photo", "Choose from Library",
                  "Cancel" };
  
          AlertDialog.Builder builder = new AlertDialog.Builder(TestFragment.this);
          builder.setTitle("Add Photo!");
          builder.setItems(items, new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int item) {
                  boolean result= Utility.checkPermission(TestFragment.this);
  
                  if (items[item].equals("Take Photo")) {
                      userChoosenTask ="Take Photo";
                      if(result)
                          cameraIntent();
  
                  } else if (items[item].equals("Choose from Library")) {
                      userChoosenTask ="Choose from Library";
                      if(result)
                          galleryIntent();
  
                  } else if (items[item].equals("Cancel")) {
                      dialog.dismiss();
                  }
              }
          });
          builder.show();
      }
  </code></pre>
  
  <p>After this </p>
  
  <pre><code> private void galleryIntent()
      {
          Intent intent = new Intent();
          intent.setType("image/*");
          intent.setAction(Intent.ACTION_GET_CONTENT);//
          startActivityForResult(Intent.createChooser(intent, "Select File"),SELECT_FILE);
      }
  
      private void cameraIntent()
      {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          if (resultCode == Activity.RESULT_OK) {
              if (requestCode == SELECT_FILE)
                  onSelectFromGalleryResult(data);
              else if (requestCode == REQUEST_CAMERA)
                  onCaptureImageResult(data);
          }
      }
  
      private void onCaptureImageResult(Intent data) {
          bitmap = (Bitmap) data.getExtras().get("data");
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
  
          File destination = new File(Environment.getExternalStorageDirectory(),
                  System.currentTimeMillis() + ".jpg");
  
          FileOutputStream fo;
          try {
              destination.createNewFile();
              fo = new FileOutputStream(destination);
              fo.write(bytes.toByteArray());
              fo.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          imgvcomp.setImageBitmap(bitmap);
  
          String img=getStringImage(bitmap);
  
          Log.v(TAG,"base64"+img);//perfectly string base64 to image
  
  
      }
  
      @SuppressWarnings("deprecation")
      private void onSelectFromGalleryResult(Intent data) {
  
  
          if (data != null) {
              try {
                  bitmap = MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), data.getData());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
  
          imgvcomp.setImageBitmap(bitmap);
          String img=getStringImage(bitmap);
  
            Log.v(TAG,"base64"+img);//checking in log base64 string to image cropeed image found
  
      }
  
  
  
  
      public String getStringImage(Bitmap bmp){
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          bmp.compress(Bitmap.CompressFormat.JPEG, 90, baos);
          byte[] imageBytes = baos.toByteArray();
  
          String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
          return encodedImage;
      }
      private void showToastMessage(String message) {
          Log.v(TAG, String.format("showToastMessage :: message = %s", message));
  //        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
      }
  </code></pre>
  
  <p>why i found the cropped image after selecting from galary?there is no error in error log here is the logcat</p>
  
  <pre><code>  E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/
   W/FlurryAgent: Flurry session paused for 
  1 and remote module com.google.android.gms.tagmanager:8
   Selected remote version of com.google.android.gms.tagmanager, version &gt;= 8
  No container asset found in /assets/containers. Checking top level /assets directory for container assets.
   Tag Manager's event handler WILL NOT be installed (no container loaded)
   Tag Manager initilization took 274ms
  Using measurement service
  Connecting to remote service
   Connected to remote service
   Processing queued up service tasks: 1
   Suspending all threads took: 25.809ms
   V/help: /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsK
                                                                CwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQU
                                                                FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAzABywDASIA
                                                                AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
                                                                AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
                                                                ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
                                                                p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
                                                                AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
                                                                BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
                                                                U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
                                                                uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD6T2jo
                                                                BtXg/jUj87uDyOn9aY6+VyxBHqOaI33xkjO04wOlcCaa0NdVuhOhYMuZDxjOCaaCR/sntmnSdQeS
                                                                RjDUqReaSQQPr1BprXca0EAJUjnPr701UBIUdBz604KEQlgNuT34NP4LDbjHX0P0pLQaZGFBDNjg
                                                                dAfWkCEsC/Bx25qQcZB6n06CmkHIY4Kjj3rO+40roiW3VMEsWcc7j1P9KmAyS2BnGTnmm71kOR0B
                                                                OTT1GUJB46Y7mpauFrsjU9AFyewpXwgOAATyccCl2b8HoR07ZpCCASQCT171SJvYYwCspC/XNI2B
                                                                kHtTpFGdoBJ44PY0sjDnocdhT6FJJjDCu0+h79zTHQBtwXn1/wAal24O4cA0igK5B5HfHSnuSmNL
                                                                HDdAQPrimlgdueFGD7U5QccgsCcAinMMlflGBwc96SEN5BYlsgngD+dIS7E4wQOoJp6rllZQFPUA
                                                                +lN8lmYHOF65Hf8ACmnYLkWBkEZHocZoiTYSrDO4dAcjNTMpJO3Bx6VHs2Fjzk9qpAIQCuAAAvpS
                                                                BOOVyBzmpDCQCFIye5/nSnAU87ccY7UrWBDOO5z605W2ggqGPbPFKIlIHrjihIuCTgsRgjHeloBH
                                                                AgSOQ9MnPFPBLNkcZAwTTUI/4CvT1pfvA8Ej16GnrYAWIKAq4A5OPSlWLaGZsbunFEZCqMnOMY4p
                                                                /wB5icYPv0poLCR7UjIb6ipFTy0O1iQTnFKuTnGBihApJUjJPY07id+hNtxuGcjAPBzTApBDAAkk
                                                                AU0KifPtBGduRUqoPm4LAc5IxQK6Y54zIWfJDcDPWoWYK46gE/nVpAQAvU9c5xVe5QrgZwTk5x0q
                                                                OuoX7D1jXqpwew6imxBgoBOSOQcYFELErtOOMYFK4by2y20cHj0pD8iN+GaM5Ljn6CidCygLgngY
                                                                7AU/fj5QOvQnqaUkgENwxxxmgFoiAny8bhlemaR025wCec5qfcEBB5OM+tMIDdz7EcYp9R2voRY2
                                                                Pwu52HQnggU5R5ZbIwpwSOtSLBlCWO1hzxQGOSCPl6VS12I13I8jaw6kcgU3LtDjLLnk55zipWiJ
                                                                LEYK9MdxTY8KG3NgHovqaqL0E0kMCs67zgEce9KCxVvnLfyFPDEKQFCjt70Fi2AFwQPmC8k0nqIY
                                                                rKTk8joSehoXMgJA4HQ9ARSxnb838AIC5GAfw9KkDndzk454HWl0AYhEgLcYGM/4ih1yxDAZx16i
                                                                lWNZGDL93sf6f/Wp5RScjg8DHXFVEBFGFxkHHPPUUY24yxNATc3Ulh1HamvtHfk9u9VF6CtcXZ1O
                                                                SR1weDTUAAYKM4PboKVs8L1B/A4pqnBODge4qxIdu3qTxg8EH1qMruyByR3AqQPgMQCPYc0iAbWb
                                                                OCeATS3HsIoUgE8k8HPpQVIkBOPL6be9IMbwNpy3IGeBSh8Io2ggHips+4hXCtuCk7icH3rD8Trj
                                                                T5lBwduP/rVvF1aMgA5HrwRXPeLH8uzcDkFce59qol7HxJ+0OHlvJVQKXXcFkxnGTyMccZA7814b
                                                                eRN54YqofABYDGQPT+te1/HaZP8AhJH864cRsDEqqMquOSevU46+2O1eM3EHmSrKHfywCAFGR14P
                                                                48/rXp0VZWv5/eckm7tldLdigkwIwfukjg+tVJJftbPJ1kXC9O3QcVYTa65+bd12vkHr6UQfPNLK
                                                                ibAOdu44Qeg9j3yeuKwvyvXuU2t0QLtMbq2WBOSp4GR3+vvUcscakFhkkY6ckfzqyMrAc4eTOVAG
                                                                M88/lVZlE8yv1Kc5JwPr+FVp0VhWGS/v22Sg4AyGXrx0z/nNNDNIxITkYBJOMemB6e9TxoTnJAGc
                                                                56j2piA4AOC7HgZ4GO+a1t7trgtBPKkBUlf3i8Njkn0J9/p7UfvI2dxgcDBIyFNS27YkKnBKDOc5
                                                                P4etP+a6Rgilmz93vmmnqmtDNvQsWkjGVQHZoyo3MqknnqcdeP8A69fU/wCzjpaFbW3TKIhXAI5X
                                                                /OMYr5f8OwGSd48Ha5ByDgr6kHrnvxX2P+zXZGSK1lRsKpyCwJOAcZyefT360TSUWKLu7n03Yrsg
                                                                WJW3YAwenHv71biQ+UQWCk9R1/Gq8EKrGdo2ggfN3NSnnK4ORwK827aOlK1iePptJDYPB9qmVOBg
                                                                k47dKrxIxUYAVx1BqxGrBcuwBAySOAPekbJaCkAYPAPXFNb943Iz3wPX1oT75OST69frQsLKWPAJ
                                                                PXrQMVSCDjBI7npSLyCWII7ZGcUOp+7yoPJxSgAjgEjON3SnfSwxfLwBg4Hr60u8cMuQem00zZwV
                                                                AyO4zSqrB85zxwaaABFtWQABR6DqKI02IF3Z7+1LjqSTkfrR8+AcbB6NyT9K0uwsABQsDgkjHH+f
                                                                1qGWPGWJzgd+uPepm+6R9PYgVA8gWNySGx044rJkO6Z518VLhbfS5nBBGCMZ56HB+gr8/vihcTX2
                                                                vX7kIwYgIynAwMtz2yNx6dPrmvtf47eIYtJ0m6lmPkoMhsDJUAZJA9gDkV8L+LbndLJ5oLbpCwwP
                                                                ckE9u9englyxb7/53OWsrtHB3UgiXfvPJw3YD/OKgub4shEZ5HO1sjn1rYkMc7yBYiy4wGbgZ7gD
                                                                296yLi0fzgpIaOMZZsfez6emK3bin7xEU1oyrDGsiZ6M3JY+nr9aLhZIE2sBscHbgYB96ZNFKroU
                                                                f92zAccE47USpNKrAjB/2hgA9v8A9YrGXWz3LirO6GCfklwOBwB0BqL7M8agSoVZ/m3ZyMe3tTJI
                                                                ZGbAIDr1BPB/xqWRXKNuXK8cdzWHLrobRtEjhHyoHIV1Odw5B/8A1U2VpJI9y4KE9Scfj709JUUc
                                                                qE3c7fSmy7ZI2LP+742oB90+3fn3rFxfM77aGyd1oVfUAhj7cCpbYSNEysQrHjaOlQyKA4K5XA65
                                                                71NCrLHuZg4PTAwa0aTVirkDWmVZWwyk4YDgH0qSG1YMwABXgjB5pFkjZ2bac9xg4/z704XRi3Lg
                                                                IHGBnr/k09e5LaW4pzIiZGfLGBzyoJpl45KZTBxwPQU2FzudASQuC2Rz7Zp5k3KQRhuoI5x+Hf61
                                                                SbWotCrAgU9CWYjdj09frUj7SxC8gc5PAxTgSyZiwc8ZHYd+aTeEZ14IYck9DU66u5peysRhQ4Ib
                                                                DEEEsOBSM6BgYyCoHDDpT/3bxN8uQOoPQ/UVHDEuWAOGPTA6UyGk9GPExAJRNzEjO
  </code></pre>