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

Crop bug if Ratio width < height #52

Open
Z6P0 opened this issue Feb 1, 2024 · 6 comments
Open

Crop bug if Ratio width < height #52

Z6P0 opened this issue Feb 1, 2024 · 6 comments

Comments

@Z6P0
Copy link

Z6P0 commented Feb 1, 2024

I tested with ratio: Ratio(width: 2, height: 3) and the cropped image does not match.
It works with square and width > height.

@RockyPanchal
Copy link

RockyPanchal commented Feb 29, 2024

Hello, @Z6P0
I faced the same issue earlier, I understand the core code and made changes in one of the file in library. then its works fine

Please do changes in that file and check

  • in calculate_on_crop_params.dart file
    -caclulateOnCropParams function

replace below code at the end , It will definitely works,

I made changes in cropSizeHeight, cropSizeWidth parameter according to aspect ratio

final double cropSizeWidth;
final double cropSizeHeight;
if (aspectRatio > 1) {
cropSizeWidth = cropSizeMax;
cropSizeHeight = cropSizeWidth / aspectRatio;
} else {
cropSizeHeight = cropSizeMax / aspectRatio;
cropSizeWidth = cropSizeHeight * aspectRatio;
}
return OnCropParams(
cropSizeHeight: cropSizeHeight,
cropSizeWidth: cropSizeWidth,
translateScale: translateScale,
scale: scale,
);

Thanks

@TarasBounty
Copy link

TarasBounty commented Mar 21, 2024

Also face the same issue
@ikbendewilliam @vanlooverenkoen please take a look

@RockyPanchal
Copy link

@TarasBounty , Please check my answer, It will help you as i faced it and solve

@TarasBounty
Copy link

@RockyPanchal Thanks, I saw it. Hope @ikbendewilliam will fix it in the next package release and we can use it without a "fork workaround"

@ikbendewilliam
Copy link
Collaborator

Currently we are very busy with projects, if you have a fork with a fix, please create a PR so we can have this fix available for everyone :-)

@TarasBounty
Copy link

Currently we are very busy with projects, if you have a fork with a fix, please create a PR so we can have this fix available for everyone :-)

@RockyPanchal

TarasBounty added a commit to TarasBounty/flutter-custom-image-crop that referenced this issue Jul 29, 2024
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

4 participants