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

How does minimumImageSize works? #57

Open
jodinathan opened this issue Dec 27, 2024 · 6 comments
Open

How does minimumImageSize works? #57

jodinathan opened this issue Dec 27, 2024 · 6 comments

Comments

@jodinathan
Copy link

I'm trying to crop images with a minimum rectangle size of 200x300 pixels. What should I set as the minimumImageSize to ensure it adheres to these dimensions?

@deakjahn
Copy link
Owner

deakjahn commented Dec 27, 2024

The documentation of CropImage happens to describe this situation:

/// The maximum pixel size the crop rectangle can be grown to.
///
/// Defaults to infinity.
/// You can constrain the crop rectangle to a fixed size by setting
/// both [minimumImageSize] and [maximumImageSize] to the same value (the width) and using
/// the [aspectRatio] of the controller to force the other dimension (width / height).
/// Doing so disables the display of the corners.
final double maximumImageSize;

If you only want to constrain the lower end, then the maximumImageSize can be larger.

@jodinathan
Copy link
Author

I don't think I'm understanding this correctly.

How can I ensure the minimum width is constrained to 200 pixels?

I've tried setting the minimumImageSize to 200, but it still allows cropping to a smaller width.

@deakjahn
Copy link
Owner

I've just tried it in the example, aspectRatio: 1.5 in the controller, minimumImageSize: 200 for the CropImage itself, and it seems to work to me. What do you experience different?

@jodinathan
Copy link
Author

I am trying the aspectRatio of 2/3 with minimumImageSize of 200 but it allows smaller width

@deakjahn
Copy link
Owner

deakjahn commented Dec 27, 2024

Although it shouldn't depend on anything like this, but what platform do you try it on?

This is a recording from the Android emulator in the IDE, width 200, aspect ratio 1.5, and it visibly has a minimum. I also tried to put a few debug readouts in crop_image.dart around lines 420-460 to see but I'm still not yet sure how to reproduce this.

Bother, first it didn't accept it, too large. Then I cut it, wrong format. Then I converted it, it no longer displays here. :-)

@deakjahn
Copy link
Owner

Screen_recording_20241227_222210_edit.mp4

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

No branches or pull requests

2 participants