我有一个应用程序,其功能可以将图像上传到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度。
提前谢谢!干杯!
提供截图:
上传前:
上传后: