Fix preview to show actual capture aspect ratio
Changes: 1. Preview layer now uses .resizeAspect instead of .resizeAspectFill - Shows exactly what will be in the captured photo - No cropping - what you see is what you get - Ring light naturally fills any letterbox areas 2. Session preset changed from .high to .photo - Optimized for photo capture - Consistent 4:3 aspect ratio - Better quality for selfies This ensures the preview accurately represents the final photo, eliminating surprise cropping in captured images.
This commit is contained in:
parent
80976c61d1
commit
e66487cabf
@ -128,7 +128,9 @@ class CameraPreviewUIView: UIView {
|
|||||||
|
|
||||||
if let layer = self.layer as? AVCaptureVideoPreviewLayer {
|
if let layer = self.layer as? AVCaptureVideoPreviewLayer {
|
||||||
layer.session = session
|
layer.session = session
|
||||||
layer.videoGravity = .resizeAspectFill
|
// Use .resizeAspect to show exactly what will be captured
|
||||||
|
// The ring light fills any letterbox areas naturally
|
||||||
|
layer.videoGravity = .resizeAspect
|
||||||
previewLayer = layer
|
previewLayer = layer
|
||||||
viewModel.previewLayer = layer
|
viewModel.previewLayer = layer
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,8 @@ class CameraViewModel: NSObject {
|
|||||||
guard let session = captureSession else { return }
|
guard let session = captureSession else { return }
|
||||||
|
|
||||||
session.beginConfiguration()
|
session.beginConfiguration()
|
||||||
session.sessionPreset = .high
|
// Use .photo preset for optimal photo quality and consistent 4:3 aspect ratio
|
||||||
|
session.sessionPreset = .photo
|
||||||
|
|
||||||
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: isUsingFrontCamera ? .front : .back)
|
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: isUsingFrontCamera ? .front : .back)
|
||||||
guard let device, let input = try? AVCaptureDeviceInput(device: device) else { return }
|
guard let device, let input = try? AVCaptureDeviceInput(device: device) else { return }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user