Fix bug where JPEG is saved with PNG filename

This commit is contained in:
Matthieu 2022-08-21 00:20:05 +02:00
parent 370efe184b
commit ace7f92a2c
1 changed files with 3 additions and 3 deletions

View File

@ -392,14 +392,14 @@ class CameraFragment : BaseFragment() {
// Get a stable reference of the modifiable image capture use case
imageCapture?.let { imageCapture ->
// Create output file to hold the image
// Create output file to hold the image. CameraX saves a JPEG image to this file,
// so it makes no sense to use another extension here
val photoFile = File.createTempFile(
"cachedPhoto", ".png", context?.cacheDir
"cachedPhoto", ".jpg", context?.cacheDir
)
// Setup image capture metadata
val metadata = Metadata().apply {
// Mirror image when using the front camera
isReversedHorizontal = lensFacing == CameraSelector.LENS_FACING_FRONT
}