[camera] Add setImageQuality for JPEG compression control#11155
[camera] Add setImageQuality for JPEG compression control#11155Bolling88 wants to merge 9 commits intoflutter:mainfrom
Conversation
|
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. |
There was a problem hiding this comment.
Code Review
This pull request introduces the setImageQuality method to control JPEG compression quality for still image captures across the camera plugin. The implementation is federated, with platform-specific logic for Android (Camera2 and CameraX) and iOS. The Android Camera2 implementation uses CaptureRequest.JPEG_QUALITY. The CameraX implementation recreates the ImageCapture use case to apply the quality setting, preserving any locked capture orientation. The iOS implementation re-encodes JPEG images to the specified quality while retaining EXIF metadata. The changes are accompanied by updates to the platform interface, method channels, and comprehensive tests for each platform.
Adds `setImageQuality(int quality)` (1-100 scale) across the camera plugin ecosystem to allow developers to control JPEG compression quality for still image capture. Users who do not call setImageQuality retain the platform's native default behavior. Implementation details per platform: - Platform interface: abstract method + method channel implementation - App-facing: CameraController.setImageQuality with range validation - Android (Camera2): JpegQualityFeature using CaptureRequest.JPEG_QUALITY - Android (CameraX): Recreates ImageCapture with Builder.setJpegQuality, preserving locked capture orientation - iOS (AVFoundation): EXIF-preserving JPEG recompression via CGImageSource/CGImageDestination (ImageIO), gated on JPEG format only
8c7c979 to
52b4cff
Compare
CameraTest and CameraTest_getRecordingProfileTest implement CameraFeatureFactory but were missing the new createJpegQualityFeature method, causing compilation failures.
|
Thanks for the contribution!
In the future, please use our checklist rather than replacing it with one you have invented. Our checklist is standardized for a reason.
Please provide the actual issue this is related to. That's not even a |
Versions 0.7.1 (camera_android_camerax) and 0.10.1 (camera_avfoundation) were already taken by upstream changes. Bumps to next minor and includes upstream CHANGELOG entries.
Sorry for that! My first contribution, and still learning! Regarding the issue, I just took a placeholder and forgot to change it. This is rather a feature improvement than resolving an issue, but I found and linked a closed issue where one of the comments requested the possibility to set image quality. If that is not enough, can I just create a new issue? |
As with almost every project, we track bug reports and feature requests in the same issue tracker.
An issue that was fixed seven years ago does not provide an explanation of what current use case needs new APIs. If there isn't an issue covering the use case you are trying to address, then you should file one. |
Thank you for your patience. I have created a new issue ticket that clearly explains the problem/feature. |
Adds
setImageQuality(int quality)(1–100 scale) across the camera plugin ecosystem, allowing developers to control JPEG compression quality for still image capture. Users who do not callsetImageQualityretain the platform's native default behavior.Packages changed
camera_platform_interfacecameraCameraController.setImageQualitywith 1–100 range validationcamera_androidJpegQualityFeatureusingCaptureRequest.JPEG_QUALITY(Camera2)camera_android_cameraxImageCaptureviaBuilder.setJpegQuality; preserves locked capture orientationcamera_avfoundationCGImageSource/CGImageDestination(ImageIO), gated on JPEG format onlyPlatform implementation details
JpegQualityFeaturesetsCaptureRequest.JPEG_QUALITYon the capture request builder. Lazily registered so users who never callsetImageQualitykeep the device HAL's native default.setJpegQualityatImageCaptureconstruction time, sosetImageQualityunbinds the currentImageCaptureand recreates it with the requested quality. Locked capture orientation is preserved across recreation.CGImageDestinationwithkCGImageDestinationLossyCompressionQuality, preserving all EXIF metadata from the original capture. HEIF captures are passed through unmodified.Fixes flutter/flutter#183229
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2