0

My app involves users choosing a photo from the gallery which then returns the URI. To upload this image onto my Firebase Google Storage I perform the following operations on the bitmap:

val inputStream = contentResolver.openInputStream(uri)
val bitmap = BitmapFactory.decodeStream(inputStream)
val baos = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, baos)
val imgData = baos.toByteArray()
var uploadTask = filePath.putBytes(imgData)

This successfully compresses and uploads my image. However, many images are landscape and not portrait - therefore I have to account for this and rotate the bitmap accordingly before I upload.

I discovered the ExifInterface (example of it here) however it requires API level 24 and my minimum API level is 21.

How can I get the orientation of my image and then rotate it to portrait - with a method that will work on API level 21?

Zorgan
  • 8,227
  • 23
  • 106
  • 207

0 Answers0