This fails for files that don't have a file extension and produces paths outside of the Android sandbox.
|
File("${imageFile.absolutePath.substringBeforeLast(".")}.${format.extension()}") |
Kotlin has nameWithoutExtension which uses the file name instead of the whole path.