I have an app which has a functionality that you can upload images to Parse.com. The problem is that Parse.com, after upload, rotates the image by 90 degrees. Has anyone encountered this problem? The image is taken and uploaded exactly the way it is selected from the gallery.
I have tried decoding the image to Bitmap, rotating it, and the converting it back to byteArray, but the result is that it takes the 1.5mb image (for example), and turns it into a 6.9mb one, unreadable as well.
Here is how I take and upload the image to Parse:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//Detects request codes
if(requestCode == GET_FROM_GALLERY && resultCode == Activity.RESULT_OK && data != null) {
selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Picasso.with(context)
.load(selectedImageUri.toString())
.resize(500, 500)
.centerCrop()
.noPlaceholder()
.into(profilePictureImageView, new Callback() {
@Override
public void onSuccess() {
profilePictureProgressBar.setVisibility(View.INVISIBLE);
profilePictureHolderImageView.setVisibility(View.INVISIBLE);
profilePictureImageView.setVisibility(View.VISIBLE);
}
@Override
public void onError() {
profilePictureProgressBar.setVisibility(View.VISIBLE);
profilePictureHolderImageView.setVisibility(View.VISIBLE);
profilePictureImageView.setVisibility(View.INVISIBLE);
}
});
}
}
if (selectedImagePath != null) {
try {
image = utils.readInFile(selectedImagePath);
} catch (IOException e) {
e.printStackTrace();
}
imageFromPhone = new ParseFile("picture", image);
imageFromPhone.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
ParseUser.getCurrentUser().put("pictureURL", imageFromPhone.getUrl());
ParseUser.getCurrentUser().saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
dialog.dismiss();
Toast.makeText(getActivity(), "Changes saved!", Toast.LENGTH_SHORT).show();
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.linearLayout_viewFeedItemLayout_textViewContainer, new ProfileFragment()).commit();
}
});
}
});
[...]
As i said, the upload works perfectly, but it rotates the image by 90 degrees.
Thank you in advance! Cheers!
Provided screenshots:
Before upload:
After upload: