🌱 dreaming DiNO
[Kotlin] Uri 로부터 Exif 값 얻고 설정 변경하기 본문
// Exif Orientation 값 확인
val exif = ExifInterface(context?.contentResolver?.openFileDescriptor(resultUri, "rw", null)!!.fileDescriptor)
val exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
VCDebugLog.i(logTag, "before: $exifOrientation") // 0
exif.setAttribute(ExifInterface.TAG_ORIENTATION, (ExifInterface.ORIENTATION_NORMAL).toString())
exif.saveAttributes()
val exif2 = ExifInterface(context?.contentResolver?.openFileDescriptor(resultUri, "rw", null)!!.fileDescriptor)
VCDebugLog.i(logTag, "after: ${exif2.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)}") // 1
처음에는 inputStream 으로 읽어와서 saveAttributes() 를 해줬는데, Bad Error 가 나서
fileDescriptor로 읽어오는 방법으로 바꿔주었다.
'Android > Android Studio' 카테고리의 다른 글
[Kotlin] arrayList에 담긴 특정 값 만 return 하기 -> .find() (0) | 2023.03.10 |
---|---|
[Kotlin] arrayList<CSVData> 에서 파일 이름이 같으면 삭제하기 (0) | 2023.03.08 |
[Android Studio] 라이브러리 .aar 교체 (0) | 2022.09.22 |
[Kotlin] Uri <-> String (0) | 2022.08.26 |
[Android] Debug 모드와 tip (0) | 2022.07.26 |