camera-preview icon indicating copy to clipboard operation
camera-preview copied to clipboard

Use photo preset to remove excess zoom on ios 17+

Open TreehouseNorris opened this issue 9 months ago • 0 comments
trafficstars

Summary:

Fixes issue where iOS 17 & 18, CameraPreview.start { position: rear, disableAudio: true, enableHighResolution: false }, with no use of any CameraPreview.setZoom, was showing a more zoomed in feed than the native Camera app did.

Task Links:

PR #339 Issue #180

Test Instructions:

Place iOS device on a stack of books overlooking a computer keyboard, to keep an identical device position. Use the native Camera app to take a photo of the keyboard. Create code that shows the prior photo with partial transparency over the fullscreen CameraPreview.start feed. Verify that the preview feed matches the scale of the key outlines and lettering in the reference photo.

Developer Notes:

I tested my solution on an iPhone 12 Pro iOS18.3 (which has multiple rear cameras, devicePixelRatio of 3) and an iPad (no notch, only has one rear camera, devicePixelRatio 2) iOS 17, and the fix showed correctly on both. Update: Verified this works on iPhone 11 iOS18 (the zoom amount was correct, for the placement: instead of modifying AVLayerVideoGravity.resizeAspectFill, it needed the below for its devicePixelRatio of 2)

CameraPreview.start({
x: myPointX * (isPlatformIos() ? window.devicePixelRatio/2 : 1),
y: myPointY * (isPlatformIos() ? window.devicePixelRatio/2 : 1),
})

TreehouseNorris avatar Feb 14 '25 14:02 TreehouseNorris