π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: calculate video rotation renderSize from actual transformed bounds
Prateek Sunalbbb03650cd1d
diff --git a/mobile/packages/native_video_editor/ios/Classes/NativeVideoEditorPlugin.swift b/mobile/packages/native_video_editor/ios/Classes/NativeVideoEditorPlugin.swiftindex 5d5e2512f2..c98e26571b 100644--- a/mobile/packages/native_video_editor/ios/Classes/NativeVideoEditorPlugin.swift+++ b/mobile/packages/native_video_editor/ios/Classes/NativeVideoEditorPlugin.swift@@ -296,25 +296,22 @@ public class NativeVideoEditorPlugin: NSObject, FlutterPlugin {transform = transform.rotated(by: clockwiseRadians)transform = transform.translatedBy(x: -centerX, y: -centerY)- // Set renderSize based on rotation- var renderSize: CGSize- if abs(degrees) == 90 || abs(degrees) == 270 {- renderSize = CGSize(width: orientedSize.height, height: orientedSize.width)- } else {- renderSize = orientedSize- }-- // Use bounds testing to calculate the necessary translation to center the video+ // Calculate renderSize from actual transformed bounds (more accurate for metadata-rotated videos)// Use naturalSize here because transform expects input in natural/file coordinate spacelet testRect = CGRect(origin: .zero, size: naturalSize)- let finalBounds = testRect.applying(transform)+ let transformedBounds = testRect.applying(transform)++ // Get the actual dimensions after the full transform chain+ let finalWidth = abs(transformedBounds.width)+ let finalHeight = abs(transformedBounds.height)+ let renderSize = CGSize(width: finalWidth, height: finalHeight)// Center the video in the renderSize- let targetMinX: CGFloat = (renderSize.width - finalBounds.width) / 2- let additionalTranslateX = targetMinX - finalBounds.minX+ let targetMinX: CGFloat = (renderSize.width - transformedBounds.width) / 2+ let additionalTranslateX = targetMinX - transformedBounds.minX- let targetMinY: CGFloat = (renderSize.height - finalBounds.height) / 2- let additionalTranslateY = targetMinY - finalBounds.minY+ let targetMinY: CGFloat = (renderSize.height - transformedBounds.height) / 2+ let additionalTranslateY = targetMinY - transformedBounds.minYtransform = transform.concatenating(CGAffineTransform(translationX: additionalTranslateX, y: additionalTranslateY))@@ -699,24 +696,22 @@ public class NativeVideoEditorPlugin: NSObject, FlutterPlugin {transform = transform.rotated(by: clockwiseRadians)transform = transform.translatedBy(x: -centerX, y: -centerY)- // Set renderSize based on rotation- if abs(rotateDegrees) == 90 || abs(rotateDegrees) == 270 {- renderSize = CGSize(width: orientedSize.height, height: orientedSize.width)- } else {- renderSize = orientedSize- }-- // Use bounds testing to calculate the necessary translation to center the video+ // Calculate renderSize from actual transformed bounds (more accurate for metadata-rotated videos)// Use naturalSize here because transform expects input in natural/file coordinate spacelet testRect = CGRect(origin: .zero, size: naturalSize)- let finalBounds = testRect.applying(transform)+ let transformedBounds = testRect.applying(transform)++ // Get the actual dimensions after the full transform chain+ let finalWidth = abs(transformedBounds.width)+ let finalHeight = abs(transformedBounds.height)+ renderSize = CGSize(width: finalWidth, height: finalHeight)// Center the video in the renderSize- let targetMinX: CGFloat = (renderSize.width - finalBounds.width) / 2- let additionalTranslateX = targetMinX - finalBounds.minX+ let targetMinX: CGFloat = (renderSize.width - transformedBounds.width) / 2+ let additionalTranslateX = targetMinX - transformedBounds.minX- let targetMinY: CGFloat = (renderSize.height - finalBounds.height) / 2- let additionalTranslateY = targetMinY - finalBounds.minY+ let targetMinY: CGFloat = (renderSize.height - transformedBounds.height) / 2+ let additionalTranslateY = targetMinY - transformedBounds.minYtransform = transform.concatenating(CGAffineTransform(translationX: additionalTranslateX, y: additionalTranslateY))