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

Constrained crop aspect ratio in range #519

Open
inamiy opened this issue Apr 25, 2022 · 4 comments
Open

Constrained crop aspect ratio in range #519

inamiy opened this issue Apr 25, 2022 · 4 comments
Assignees
Labels

Comments

@inamiy
Copy link

inamiy commented Apr 25, 2022

Hi @TimOliver 👋

Is it possible to control the result image size to be within certain aspect-ratio range?

For example, suppose dev wants to have square-ish image (1:1) which can be vertically long at most by 9:16.
In such case, if user controls grid to be vertically longer than 9:16, the grid automatically force-shrinks down to max 9:16.

I have taken a quick look at the code if delegate calls can be a good place to tweak the aspect ratio of the grid, but seemed it's not an easy fix.

It will be nice if there is a quick way of handling this kind of constrained aspect ratio, and also would be nicer if there will be such property, e.g.:

cropViewController.minAspectRatio = CGSize(width: 9, height: 16)
cropViewController.maxAspectRatio = CGSize(width: 1, height: 1)

(P.S. Using ClosedRange is better, but probably not possible as aspect-ratio uses CGSize and also needs to be interpretable in ObjC!)

@sugitatestblue
Copy link

I guess minAspectRatio -> minimumAspectRatio

@TimOliver
Copy link
Owner

TimOliver commented May 2, 2022

Hey @inamiy! Long time no see! I hope you've been going well! 😁

Hmm, interesting! So the idea is to have an "aspect ratio" range that the crop box can change shape inside?

Yeah, I feel like the delegate would be too late for that, but maybe it's not so hard to change the layoutSubviews logic to change how the crop box is allowed to resize to support this.

Do you have some examples of some input/output images you would like to see from this sort of feature?

@inamiy
Copy link
Author

inamiy commented May 2, 2022

Yes, it's about restricting the crop box size to not become too long on one side!

I don't have a clear image yet on how the UX will be like.
It will be nicer if dev can customize error behavior when crop-box reaches to the error size,
e.g. show HUD, have haptic feedback and auto-resizing, etc.

I think auto-resizing is the easiest start, as well as providing its delegate method so that dev can additionally present custom HUD for warning message.

Crop-box size error detection timing is also another thing to consider.
I think errors on touchesEnded is more preferred than touchesMoved for now, as current impl also has auto-cropbox-resizing animation on touchesEnded after delay, and single-shot per gesture is probably easier to manage.

@inamiy
Copy link
Author

inamiy commented May 2, 2022

One another idea is to have a crop-box frame to have a 🟥 red color during touchesMoved so that users will be aware of invalid size but doesn't need to see custom error messages until touchesEnded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants