Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for allowed aspect ratios [CC-708] #40

Merged
merged 3 commits into from
Mar 12, 2024

Conversation

iirovi-rs
Copy link
Collaborator

@iirovi-rs iirovi-rs commented Mar 6, 2024

This PR adds support for a bunch of configuration variables allowing setting lists of "allowed aspect ratios" for single-video and multi-asset scenarios. The videos (or media, in the case of multiple selection) will be auto-cropped to the nearest aspect ratio from the list. An "override" list is also provided for both scenarios (single video and multi-selection), allowing for a situation where we'll want to allow certain aspect ratios to be "always allowed" but never selected automatically.

Additionally, it adds a configuration value for "max video resolution", which allows setting a maximum value for the resulting processed video's pixel count (height * width). It also automatically rounds the resulting width and height values to the nearest even number, which is a requirement for many video post processing use cases.

@iirovi-rs iirovi-rs changed the title feat: Add support for feat: Add support for allowed aspect ratios [CC-708] Mar 6, 2024
Source/Configuration/YPImagePickerConfiguration.swift Outdated Show resolved Hide resolved
@@ -305,7 +302,50 @@ fileprivate extension YPAssetZoomableView {
self?.centerAssetView()
}
}


func findClosestAllowedAspectRatio(for aspectRatio: CGFloat) -> CGFloat {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be nice to have a test for but we don't have that established in the image picker library nor do we have the CI infrastructure setup to run tests even if we did have them here 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah true. Maybe it would be worth it to just add a simple unit test file for this, even if it's not automated in the CI.

@iirovi-rs iirovi-rs force-pushed the feat/CC-708-allowed-aspect-ratios branch from 873a271 to d2a0cc9 Compare March 7, 2024 22:57
@iirovi-rs iirovi-rs force-pushed the feat/CC-708-allowed-aspect-ratios branch from a3a8d78 to ba6e260 Compare March 11, 2024 19:57
@iirovi-rs iirovi-rs changed the base branch from CC-550-when-selecting-media-display-auto-cropping-for-additionally-selected-media-assets to master March 11, 2024 19:58
@@ -234,6 +237,15 @@ open class LibraryMediaManager {
} else {
// transfer the transform so the video renders in the correct orientation
videoCompositionTrack.preferredTransform = transform
videoComposition?.renderSize = videoSize

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 236, can probably clean up that comment right? I think we determined that videoComposition?.renderSize = cropRect.size is needed? (based on Slack convo)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah sure, I'll clean it up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now.

@iirovi-rs iirovi-rs force-pushed the feat/CC-708-allowed-aspect-ratios branch from ba6e260 to aa915ae Compare March 11, 2024 21:48
@iirovi-rs iirovi-rs merged commit ecc16c0 into master Mar 12, 2024
2 of 3 checks passed
@iirovi-rs iirovi-rs deleted the feat/CC-708-allowed-aspect-ratios branch March 12, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants