I am capturing images using Camera API and after clicking the image it is auto rotating it to 90 degree, to overcome this issue I am using Matrix to rotate the orientation by using following code:
var angle = 90f
val mat = Matrix()
mat.postRotate(angle)
val bmp = BitmapFactory.decodeStream(FileInputStream(picture), null, null)
// mat.postScale(1f, -1f, bmp!!.width / 2f, bmp.height / 2f);
val correctBmp =
Bitmap.createBitmap(bmp!!, 0, 0, bmp!!.width, bmp.height, mat, true)
But the issue is with this code it is successfully rotating the image to 90 degree but when i send the file to server then it uploads the file to server before rotating so i need a fix something like which can rotate the image inside the file too.
I have tried to write the bitmap inside a new file by using bitmap.compress but it is giving "broken pipe" error while uploading the image to server. So please suggest me any workaround for this.