I am getting image from gallery and trying to reduce its quality before uploading it on a server but I am not getting it how to do it correctly.
Below is my code:
openGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent();
i.setType("image/*");
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(i,"Select picture"),GALLERY_IMAGE);
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_IMAGE && resultCode == RESULT_OK && data != null){
selectedImage = data.getData();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),selectedImage);
} catch (IOException e) {
e.printStackTrace();
}
if(bitmap != null){
bookImage.setImageBitmap(bitmap);
}
}
else{
TastyToast.makeText(getApplicationContext(),"No image selected",TastyToast.LENGTH_SHORT,TastyToast.INFO).show();
}
}
Someone please let me know what should I add in above code to get result any help would be appreciated.
THANKS