Possibly you are rotating the matrix of the image before save it. that's why the image it´s stretched, don´t rotate the matrix and just save the correct value of orientation in the ExifInterface. Try to use something like this with your image:
ExifInterface exif=new ExifInterface(pictureFile.toString());
Log.d("EXIF value", exif.getAttribute(ExifInterface.TAG_ORIENTATION));
if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("6")){
realImage= rotate(realImage, 90);
} else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("8")){
realImage= rotate(realImage, 270);
} else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("3")){
realImage= rotate(realImage, 180);
} else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("0")){
realImage= rotate(realImage, 45);
}
Other way it´s that your Byte Array it´s already saved with a wrong Orientation, in that case you must go to your code and check which parameter are you using when you create your ContentBuilder, check your MediaService parameter:`
MediaStore.Images.ImageColumns.ORIENTATION
Finally I had a similar problem but not with the saved image, it was with the camera preview, the problem appear when I didn't reset my camera session, so the buffer have a different size. Check the post, maybe it will help you with the solution or the code to resize the image.
Camera PreviewView is stretched in some Android devices