Skip to content

Proposal:[camera] Add API to control JPEG compression quality #183229

Closed

Description

@Bolling88

Use case

The camera plugin currently provides no way to control the JPEG compression quality of captured still images. Developers who need smaller file sizes (e.g., for upload) must re-encode images in Dart after capture, which is slow and loses EXIF metadata.

Proposal

Add a setImageQuality(int quality) method to CameraController that accepts a value from 1 (maximum compression) to 100 (maximum quality). The setting applies to subsequent takePicture() calls.

Platform behavior

  • Android (Camera2): Sets CaptureRequest.JPEG_QUALITY on the capture request.
  • Android (CameraX): Recreates ImageCapture with the specified jpegQuality via ImageCapture.Builder.setJpegQuality().
  • iOS (AVFoundation): Re-encodes the captured JPEG using CGImageDestination with kCGImageDestinationLossyCompressionQuality, preserving all EXIF metadata.

Users who never call setImageQuality retain the platform's native default behavior.

Related: #30459

Activity

  1. Bolling88 commented on Mar 4, 2026

    @Bolling88
    Author

    Design: setImageQuality implementation

    PR: flutter/packages#11155

    API

    /// Sets the JPEG compression quality for subsequent [takePicture] calls.
    ///
    /// The [quality] parameter must be between 1 (maximum compression) and
    /// 100 (maximum quality).
    Future<void> setImageQuality(int quality)

    Added to CameraPlatform (platform interface) and exposed via CameraController with 1–100 range validation.

    Platform implementations

    Android (Camera2) — New JpegQualityFeature that sets CaptureRequest.JPEG_QUALITY on the capture request builder. Lazily registered so users who never call setImageQuality keep the device HAL's native default.

    Android (CameraX) — CameraX only supports setJpegQuality at ImageCapture construction time, so setImageQuality unbinds the current ImageCapture and recreates it with the requested quality. Locked capture orientation is preserved across the recreation.

    iOS (AVFoundation) — When quality < 100 and format is JPEG, re-encodes the captured photo using CGImageDestination with kCGImageDestinationLossyCompressionQuality, preserving all EXIF metadata from the original capture. HEIF captures are passed through unmodified since CGImageDestination compression quality only applies to JPEG.

    Design decisions

    • No default override: Users who never call setImageQuality retain the platform's native default behavior (device HAL default on Camera2, typically 95 on CameraX, system default on iOS).
    • Post-creation setting: Modeled as a setter rather than a constructor parameter to match the pattern of other camera settings (setFlashMode, setExposureMode, etc.).
    • JPEG-only on iOS: The quality parameter maps directly to JPEG compression. HEIF uses a different encoding pipeline and is passed through unchanged.
  2. changed the title [-][camera] Add API to control JPEG compression quality[/-] [+]Proposal:[camera] Add API to control JPEG compression quality[/+] on Mar 6, 2026
  3. added
    c: new featureNothing broken; request for a new capability
    c: proposalA detailed proposal for a change to Flutter
    packageflutter/packages repository. See also p: labels.
    platform-androidAndroid applications specifically
    platform-iosiOS applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on Mar 6, 2026
  4. added
    P2Important issues not at the top of the work list
    on Mar 10, 2026
  5. added a commit that references this issue on Apr 14, 2026
    749abe9
  6. github-actions commented on Apr 28, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Apr 28, 2026
  8. added a commit that references this issue on Jun 10, 2026
    cf2f2c8
  9. added a commit that references this issue on Jun 19, 2026
    02bfb74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyplatform-iosiOS applications specificallyteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions