0.4.2 - Fixed issue with photo upload streams
This commit is contained in:
@@ -14,8 +14,8 @@ android {
|
||||
applicationId = "com.atridad.openclimb"
|
||||
minSdk = 31
|
||||
targetSdk = 35
|
||||
versionCode = 8
|
||||
versionName = "0.4.1"
|
||||
versionCode = 9
|
||||
versionName = "0.4.2"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -35,18 +35,11 @@ object ImageUtils {
|
||||
*/
|
||||
fun saveImageFromUri(context: Context, imageUri: Uri): String? {
|
||||
return try {
|
||||
val inputStream = context.contentResolver.openInputStream(imageUri)
|
||||
inputStream?.use { input ->
|
||||
// Decode with options to get EXIF data
|
||||
val options = BitmapFactory.Options().apply {
|
||||
inJustDecodeBounds = true
|
||||
}
|
||||
input.reset()
|
||||
BitmapFactory.decodeStream(input, null, options)
|
||||
// Decode bitmap from a fresh stream to avoid mark/reset dependency
|
||||
val originalBitmap = context.contentResolver.openInputStream(imageUri)?.use { input ->
|
||||
BitmapFactory.decodeStream(input)
|
||||
} ?: return null
|
||||
|
||||
// Reset stream and decode with proper orientation
|
||||
input.reset()
|
||||
val originalBitmap = BitmapFactory.decodeStream(input)
|
||||
val orientedBitmap = correctImageOrientation(context, imageUri, originalBitmap)
|
||||
val compressedBitmap = compressImage(orientedBitmap)
|
||||
|
||||
@@ -68,7 +61,6 @@ object ImageUtils {
|
||||
|
||||
// Return relative path
|
||||
"$IMAGES_DIR/$filename"
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user