Skip to content

camera_android_camerax: Write exposure time to EXIF when missing#11327

Open
vodemn wants to merge 1 commit intoflutter:mainfrom
vodemn:camera-android-camerax-exif-exposure-time
Open

camera_android_camerax: Write exposure time to EXIF when missing#11327
vodemn wants to merge 1 commit intoflutter:mainfrom
vodemn:camera-android-camerax-exif-exposure-time

Conversation

@vodemn
Copy link

@vodemn vodemn commented Mar 22, 2026

Description

Some devices (e.g. Honor) omit ExposureTime in JPEG EXIF when using CameraX ImageCapture.takePicture with file output. This mirrors the fix for camera_android (Camera2) in flutter/packages#11326, but targets the default Android implementation (camera_android_camerax).

What changed

  • Attach a Camera2Interop.Extender session CaptureCallback on ImageCapture to record CaptureResult.SENSOR_EXPOSURE_TIME.
  • After CameraX saves the still image, if EXIF TAG_EXPOSURE_TIME is missing, write it using androidx.exifinterface (nanoseconds → seconds), without failing the capture on EXIF errors.
  • Add androidx.exifinterface:exifinterface:1.3.7 and unit tests in ImageCaptureTest.

Tests

  • :camera_android_camerax:testDebugUnitTest --tests io.flutter.plugins.camerax.ImageCaptureTest (from the plugin example after flutter build apk --config-only).

Version

  • Bumps camera_android_camerax to 0.6.25+1 and updates CHANGELOG.

Made with Cursor

@google-cla
Copy link

google-cla bot commented Mar 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a mechanism to write the exposure time to EXIF metadata if it's missing after an image capture. It uses Camera2Interop to attach a SessionCaptureCallback to the ImageCapture use case, which records the SENSOR_EXPOSURE_TIME from the CaptureResult. After the image is saved, the code checks for the existence of TAG_EXPOSURE_TIME in the EXIF data and writes the captured value if it's absent. The implementation includes error handling to avoid failing the capture on EXIF-related issues. Unit tests have been added to verify the new EXIF patching logic under various conditions. I have one suggestion to improve code maintainability.

Some devices (e.g. Honor) omit exposure time in JPEG EXIF when using CameraX
ImageCapture.takePicture. Use Camera2Interop session capture callback to
record SENSOR_EXPOSURE_TIME and patch EXIF after save via ExifInterface when
TAG_EXPOSURE_TIME is absent.

Adds androidx.exifinterface dependency and unit tests for patchExifExposureTime.

Made-with: Cursor
@vodemn vodemn force-pushed the camera-android-camerax-exif-exposure-time branch from 481f171 to f796925 Compare March 22, 2026 10:30
@camsim99
Copy link
Contributor

@vodemn Thank you so much for this fix! I would love to review this and get this fix into the plugin.

First, though, can you resolve the missing CLA check? https://github.com/flutter/packages/pull/11327/checks?check_run_id=68072535659 can walk you through it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants