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
Support "fit to min" in addition to "fit to max". #24
Comments
@rich-j Thank you. If you see blank areas in the result image you've found a bug! Can you share some code and the steps to reproduce the bug? |
I don't think it's a bug, We use a square aspect ratio with the oval crop shape as such: child: AspectRatio(
aspectRatio: 1,
child: Crop(
controller: cropController,
shape: CropShape.oval,
child: selectedImage,
),
),
When we give it a rectangular image such as this iOS sample image it defaults the scaling to fit the max dimension (horizontal in this example) resulting in "blank" areas on the top and bottom. We don't think this is "wrong" or even a bug - this is an enhancement request. For this use case of providing a square avatar image from either a portrait or landscape image, we would like to configure |
Did you try |
btw, you do not need |
We need the return AlertDialog(
scrollable: true,
title: Text("Select avatar image"),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Hero(
tag: heroKey,
child: AspectRatio(
aspectRatio: 1,
child: Crop(
controller: cropController,
shape: CropShape.oval,
child: selectedImage,
),
),
),
... more widgets ... |
The |
I didnt understand the functionality you desire. Can you point to a library/demo/video with this functionality. Anything written in Java or Swift or for Windows would help a lot. |
@rich-j Thank you for describing the problem and the images help a lot. The last 2 images are similar. I am not getting what's wrong and what should be fixed/added as an option. This package works as you described unless you've found a bug. Can you shine more light on this? |
Another way to consider this enhancement request is to constrain the minimum final imageAspectRatio = image.width / image.height;
final minScale = imageAspectRatio < 1.0 ? 1 / imageAspectRatio : imageAspectRatio;
cropController.scale = minScale; This starts with the image filling the crop viewport and the user can adjust the image by panning into the offscreen overhang. However, the user can also pan into the areas where there is no image on the sides of the image min dimension resulting in the final cropped image having blank areas. This behavior isn't wrong - we just would like to further constrain the user from creating a final cropped image with blank areas. Constraining the We did try to implement our own constraints by adding a listener to |
No it doesn't create black bars and referring to your attached image, the blue color never appears.
Yes. This is how the package currently works.
Unfortunately i did not understand the problem yet. But i will keep working with you until it's fixed :) Please check your inbox. |
When the image first loads, there's no issue if you use the aspect ratio scale initialization as @rich-j shows in the comment above. However, when you zoom out or pan to one side, there are black bars filling out the image's shortest sides. This happens with both horizontal pictures (above) and vertical (below). The longest side is unaffected, and the user is unable to pan past its boundaries. But the user can pan out to save those black bars as part of their avatar image. Thank you for your patience with us. :) We really appreciate you taking this time. |
To put things in another context, we took a look at your demo app. This is your original image. When changing the aspect ratio to 1:1, however, using For instance, what if a user has a group photo, but they aren't posed in the middle? Using Therefore, we hope for an option for a lossless change in aspect ratio while maintaining the wonderful functionality of your widget. |
@K-Y-Johnson these black areas doesn't happen on my phone. I have attached a video (in the zip file). It shows the behavior of the package. Are you sure you are using the latest commit and have not modified the source code? |
@K-Y-Johnson has added issue #27 which focuses on the "pre-crop" issue. Let's close this issue since it descended into one possible approach of not using @xclud - please know that we think this is a really good widget and we appreciate your patience with us. |
@rich-j Would you mind sharing how you were able to get those black bars? Like xclud, I couldn't reproduce, but I would love those as part of the functionality. Thanks! |
@bkoznov I don't recall specifics since it's been over a year since I last looked at this issue. The issue is basically due to a mismatch in aspect ratios between the selected image to crop (e.g. 16:9) and the target cropped result (1:1). This issue is closed and is now being tracked in issue #27. I believe that @xclud has reproduced it and a fix is forthcoming. |
This widget is awesome! We would like a configuration option to limit scaling to fit the min dimension. The current behavior limits scaling to the max dimension.
When cropping circular (square) avatars from rectangular source images, we would like to limit the scaling fit to the min dimension such that no parts of the resulting image are blank. The current behavior limits the scaling fit to the max dimension which can result in blank areas on the min dimension sides.
For example a rectangular vertical (portrait) image cropped to a square aspect ratio has blank area on left and right sides (i.e. min dimension). The requested option would not allow the image to be scaled smaller than what fits across the min (e.g. horizontal) dimension. Currently the scaling is limited to the max dimension (in this example the vertical dimension) which can result in blank areas on the left and/or right sides.
The text was updated successfully, but these errors were encountered: