将图像上传到Parse.com默认情况下将其旋转90度。对此有何解决方案? (机器人)

时间:2015-05-29 16:36:08

标签: java android image parse-platform bitmap

我有一个应用程序,其功能可以将图像上传到Parse.com。问题是Parse.com在上传后会将图像旋转90度。有谁遇到过这个问题?图像的拍摄和上传方式与从图库中选择的图像完全相同。

我尝试将图像解码为Bitmap,旋转它,并将其转换回byteArray,但结果是它需要1.5mb图像(例如),并将其转换为6.9mb图像,不可读为好。

以下是我如何拍摄并将图像上传到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();
                        }
                    });
                }
            });
 [...]

正如我所说,上传工作完美,但它将图像旋转90度。

提前谢谢!干杯!

提供截图:

上传前: Before upload

上传后: After upload

0 个答案:

没有答案