민프
[Android][Kotlin] Exif값으로 돌아간 사진을 돌려보자!! 본문
var bitmap = MediaStore.Images.Media.getBitmap(contentResolver, uri)
var inPutStream:InputStream = contentResolver.openInputStream(uri)!!
var exif : ExifInterface? = null
try{
exif = ExifInterface(inPutStream)
}catch (e: IOException){
e.printStackTrace()
}
val manufacturer = exif?.getAttribute(ExifInterface.TAG_MAKE)
val cameraModel = exif?.getAttribute(ExifInterface.TAG_MODEL)
val orientation = when (exif?.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
ExifInterface.ORIENTATION_ROTATE_90 -> 90
ExifInterface.ORIENTATION_ROTATE_180 -> 180
ExifInterface.ORIENTATION_ROTATE_270 -> 270
else -> 0
}
val dateTime = exif?.getAttribute(ExifInterface.TAG_DATETIME)
val length = exif?.getAttribute(ExifInterface.TAG_IMAGE_LENGTH)
val width = exif?.getAttribute(ExifInterface.TAG_IMAGE_WIDTH)
Log.d("ExifData", "model : $manufacturer")
Log.d("ExifData", "model2 : $cameraModel")
Log.d("ExifData", "Orientation : $orientation")
Log.d("ExifData", "dateTime : $dateTime")
Log.d("ExifData", "Resolution(x*y) : $width x $length")
var after_bitmap = rotateBitmap(bitmap,orientation)
'[Android]' 카테고리의 다른 글
[Android][kotlin] setOnTouchListener을 이용해서 뷰 확대하기 (0) | 2021.12.16 |
---|---|
[Android][Kotlin] Delay 줘보기 (0) | 2021.10.12 |
[Android][Kotlin] textView 글자 간격 조절하기 (0) | 2021.10.09 |
[Android][Kotlin] 안드로이드 Fragment에서 Activity 호출 (0) | 2021.10.09 |
[Android][Kotlin] Switch Button 사용해보자! (0) | 2021.10.05 |
Comments