icapps/flutter-custom-image-crop

Crop bug if Ratio width < height

Z6P0 opened this issue ยท 6 comments

Z6P0 commented

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

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

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

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

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

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 :-)

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