-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Feature Request
Description
It'd be useful to have an option in CameraPreview.start() that removes letterboxing. This option would scale the image up so that no letterboxing is visible.
Platform(s)
iOS, Android, Web
Preferred Solution
A new option aspectMode: 'cover' | 'contain' could be added to CameraPreviewOptions, defaulting to 'contain', which is the current behavior.
Setting it to 'cover' removes letterboxing. Please see suggested implementation under Additional Context.
Additional Context
iOS
The preview is an AVCaptureVideoPreviewLayer. To fill without bars you set:
videoGravity = .resizeAspectFill
(Instead of .resizeAspect, which produces letterboxing.)
Android
The preview is a TextureView/SurfaceView driven by CameraX/Camera2. You need the equivalent “scale to fill” behavior:
- adjust the preview view's scale / transform matrix, or
- use a PreviewView scale type that fills (when using CameraX PreviewView), or
- compute a transform so the preview fills and crops.
Web
Simply add the following CSS to the <video> element when aspectMode is 'cover': object-fit: cover.
