View Code? Open in Web Editor
NEW
This is the app module for ESMira (https://github.com/KL-Psychological-Methodology/ESMira)
Home Page: https://esmira.kl.ac.at/
License: GNU Affero General Public License v3.0
Kotlin 81.16%
Swift 18.84%
esmira-apps's People
Stargazers
esmira-apps's Issues
Problem Description:
When taking pictures with the phone's camera using the app, the resulting images are quite large in size. This can lead to excessive storage usage and potentially impact app performance.
Proposed Solution:
Just quickly looking over the code maybe you can modify the CameraView.swift (iOS) and PhotoView.kt (Android) files to include image compression functionality.
Something like this:
Android:
val cameraLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts .TakePicture (),
onResult = { success ->
println (" onResult $success " )
if (success) {
if (tempFile.exists()) {
// compress image
val bitmap = BitmapFactory .decodeFile(tempFile.path)
FileOutputStream (tempFile).use { out ->
bitmap.compress(Bitmap .CompressFormat .JPEG , 50 , out )
}
// --------------------
if (file.exists()) {
file.delete()
}
tempFile.renameTo(file)
}
confirmImage()
image.value = BitmapFactory .decodeFile(file.path)
}
}
)
IOS:
func imagePickerController( _ picker: UIImagePickerController , didFinishPickingMediaWithInfo info: [ UIImagePickerController . InfoKey : Any ] ) {
if let image = info [ UIImagePickerController . InfoKey. originalImage] as? UIImage {
// compress image
let compressedImageData = image. jpegData ( compressionQuality: 0.5)
let compressedImage = UIImage ( data: compressedImageData)
// --------------------
parent. callback ( compressedImage ?? image)
}
}
Maybe make it optional to compress the image?
Regards,
Florian