-
Notifications
You must be signed in to change notification settings - Fork 84
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
Pre-Cropping #27
Comments
Crop defaults to center of the image when the aspect ratios are not equal. You'll never know where in the image your users want to select and crop. What if the user wants to crop the horse. Or even the flower? How do you know? You may not predict what user wants. |
It's not your task to select the human face. Users should do it. |
I agree. Users should be able to select whatever they want for their avatar, and it's not the programmer's job to select the human face. The issue is that due to The image is exactly the same as shown in my previous message, simply zoomed out. |
Can't you pan the image? Where did the last screenshot come from? I mean the one with black bars. |
No, we are unable to pan the image. That data has been cropped off. The last screenshot came from me zooming out with two fingers and holding the image while I took a screenshot. After I released the image, it snapped back to look like the second image in my first post. |
We have run this situation on iOS simulator, Android emulator and iPhone Xs, and the results are the same. |
I see the same problem, using |
Thank you for your help, @vejmelkam. We did discuss this possible solution in #24, however it then results in showing the user "missing parts" or black bars, which the user is then able to crop into their image. Allowing the user to do this is not part of our desired functionality, though it is a possible workaround. |
@xclud , here is a video demonstration of the issue: In this case, I'd like to crop the image to 16:9, but I want to capture the upper portion of the image. However, after selecting a 16:9 crop aspect ration, I am unable to pan and therefore unable to capture the upper portion of the image. Note: |
@nwparker Thank you. Now I am able to reproduce the bug. Will let you know when I fix this. Contributions are welcome :) |
I haven't had luck fixing this altogether, but it turns out out switching to However, it's not quite right as it allows cropping of areas outside of the image |
We can't simply change this parameter. I think we should change the original zoom factor, which should be determined by the size of the image and the target clipping size. |
@HeebeLee correct that scaling should be adjusted too. See the comment in related closed issue #24 (comment) final imageAspectRatio = image.width / image.height;
final minScale = imageAspectRatio < 1.0 ? 1 / imageAspectRatio : imageAspectRatio;
cropController.scale = minScale; This is not a complete solution since it doesn't constrain the user's panning/zooming to not enter the "empty" image parts. |
Hi, I am still facing this issue. Any fix? |
@momoDragon I am rewriting a part of calculations at the moment. Will publish a new version when done. This bug is over a year old now and we should get rid of it. |
1 similar comment
@momoDragon I am rewriting a part of calculations at the moment. Will publish a new version when done. This bug is over a year old now and we should get rid of it. |
I'm waiting to solve this issue and enjoy more, |
My cat needs help. |
@michaldev Sorry for the inconvenience. My own cat needs help too!. This issue is blocking version 1.0 release and i hate this. |
@xclud Hello is there any progress on that bug? Cheers |
Hi @margorski, I appreciate your contribution. I am working on |
I really appreciate the work that has been done on this package. I recognize you are doing all this work out of good will. I just wondered if any progress has been made on this issue? |
Hello @xclud I admit that I didn't do any heavy tests. Using the example app I checked all aspect ratios and it looks that it works. It could be changed but it is suitable for my project so I will keep that on the forked repo. In the next day, I will be integrating that into our app so if I will encounter any problems I will add fixes on the branch. For now, you could take a look if that is anything that will work for you. |
Still need some work with vertical images so not ready yet :) |
Ok, it looks like it is ready now. Review and see if that is a good solution to merge into your library. |
@margorski Thank you for the great job on this bug. You definitely make a a lot of people happy and you will make the package go to version 1.0. I appreciate your work on behalf on everyone using this package. |
Hello @xclud thanks for the awesome work! Do you know when it will be available version 1.0 with this bug fixed? |
In case anybody needs a ready-to-go solution, I manually applied all the outstanding PRs #66, #68, and #71, to my own fork of this repo (the PRs don't apply cleanly, because the main branch has changed too much). https://github.com/lukehutch/flutter_crop This solves the problem for me (at least with rotation disabled, I haven't tested with rotation enabled). |
Actually I spoke too soon -- @margorski your PR #71 doesn't work when cropping a 16:9 aspect ratio photo using |
@margorski I fixed the issue in your PR, but there were more issues with rotation, e.g. the bounding box calculation and minimum scale calculations were wrong. Since I don't need rotation, I just need a working crop widget, I removed rotation support from my fork (linked in a previous comment). That version is now fully functional. Somebody else is welcome to take that version and add rotation back in, if they're game to wrap their mind around the needed trignonometry. |
Lol, 2024 and still no fix |
@lukehutch 2024 and your fork is working great! Thanks a lot mate. |
We are using your widget to create square avatars. When we do so, it pre-crops the original image.
Here is an image.
Given this original image, we placed it inside your example app, changing only line 106 to reference this image (also adding it as an asset in the pubspec.yaml).
When we run the app and set a 1:1 aspect ratio, which is the functionality we want, here's what we end up with. We can't see the person of interest because of the pre-crop that occurs due to the
fit: BoxFit.cover
.Below is the desired result.
The text was updated successfully, but these errors were encountered: