1

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: Before upload

After upload: After upload

Vlad Iancu
  • 487
  • 1
  • 6
  • 15
  • IMO - its the device rotating the image not Parse.com http://stackoverflow.com/questions/13430895/capture-photo-rotate-90-degree-in-samsung-mobile and https://code.google.com/p/android/issues/detail?id=1193 – Robert Rowntree May 29 '15 at 18:25
  • Uploading a file doesn't rotate it by 90 degrees. You're looking in the wrong place. – user207421 May 29 '15 at 19:23
  • Well then why when I put in into the profilePictureImageView it has the correct orientation and after uploading it is rotated by 90? – Vlad Iancu May 29 '15 at 19:36
  • Added the screenshots. The whole process is in the code i exposed. – Vlad Iancu May 29 '15 at 20:13
  • The processing required to rotate an image by 90 degrees is miles beyond anything that could possibly happen accidentally during an upload. – user207421 May 29 '15 at 20:22
  • Yes, i imagine that. Anyway, do you happen to know any cause or solution to this? I don't know where to look. – Vlad Iancu May 29 '15 at 21:13
  • It's an EXIF info. The picture is stored always in landscape but contains a hint about the phone's orientation at the time of taking the picture. Or similar. So when you upload a portrait oriented picture a tool which ignores the EXIF info will interpret it in its original form - landscape. There you have your 90° rotation. Verify by uploading a landscape photo. – Eugen Pechanec May 29 '15 at 22:09
  • Yes, i have tested now. I uploaded a landscape photo, and it remained unchanged. If i upload a portrait photo, it rotates by 90 degrees. Thanks for this! But still, are there any solutions? – Vlad Iancu May 30 '15 at 08:01

0 Answers0