-
-
Notifications
You must be signed in to change notification settings - Fork 189
Description
Platforms
Android, iOS, Web, Windows, macOS, Linux
Description
Currently, when a fixed crop aspect ratio is set (e.g., 16/9), rotating the image causes the aspect ratio to invert (becoming 9/16). This behavior can be unintuitive and undesirable in scenarios where the developer wants to enforce a strict aspect ratio regardless of rotation.
For example:
- Set crop aspect ratio to
16/9. - Rotate the image by 90°.
- The crop area flips to
9/16automatically.
There is no configuration flag in CropRotateEditorConfigs to disable this inversion behavior.
inverted.aspect.ratio.mp4
Proposed Solution
Introduce a new configuration flag in CropRotateEditorConfigs (e.g., lockAspectRatioOrientation: true) that ensures the aspect ratio remains fixed in the defined orientation, regardless of rotation.
When this flag is enabled:
- A
16/9aspect ratio should stay16/9, even after 90° rotations. - Similarly,
9/16should remain9/16.
Additionally, this would remove the need for unnecessary swap logic when handling flips, for example:
pro_image_editor/lib/features/main_editor/main_editor.dart
Lines 2138 to 2139 in cb36967
| flipX: transform.is90DegRotated ? transform.flipY : transform.flipX, | |
| flipY: transform.is90DegRotated ? transform.flipX : transform.flipY, |
If aspect ratio orientation is locked, there should be no need to swap flipX and flipY in such cases.
Why
- Predictability: Developers often expect the crop ratio to remain exactly as defined, independent of rotation.
- User experience: End users may be confused when their intended
16/9crop suddenly switches to portrait orientation after rotation. - Simplified implementation: Avoids extra logic for handling
flipX/flipYswapping and reduces edge-case complexity. - Flexibility: Developers can still allow the current behavior by leaving the flag disabled (backward compatibility).
- Alignment with future features: Issue [Feature request] Add Skewing Support to Image Transformations #525 requests free-angle rotation. In such cases, preserving the original aspect ratio becomes even more important to avoid unexpected inversions.