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

Additional "eraser" feature #52

Closed
monsieurtanuki opened this issue May 30, 2024 · 9 comments
Closed

Additional "eraser" feature #52

monsieurtanuki opened this issue May 30, 2024 · 9 comments

Comments

@monsieurtanuki
Copy link
Contributor

In our project we now use the crop tool for receipts.
In some cases receipts contain user data inside the cropped area, and we should not display/upload it.
With an eraser button, the user would be able to erase part of the image. While still cropping it.

@deakjahn
Copy link
Owner

Sorry but this package does no image manipulation at all. It just gives the rectangle, as you know. A long shot but maybe a plugin approach that can manipulate the image separately but I really don't know if it's warranted...

@monsieurtanuki
Copy link
Contributor Author

@deakjahn What would be the solution then? I can imagine

  • Stacking an eraser widget on top of CropImage, where the user bars manually what is to be hidden
  • but then, getCroppedBitmap will return an immutable image of the cropped zone, and I'll have to copy again that cropped area in order to apply the eraser

What about adding an optional additionalDrawing parameter in getCroppedBitmap, something like void Function(Canvas)?:

additionalDrawing: (Canvas canvas) {
  final Paint myPaint = Paint()
    ..strokeWidth = SmoothBarcodeScannerVisor.STROKE_WIDTH
    ..color = Colors.white
    ..style = PaintingStyle.stroke;
  canvas.drawPath(myPath, myPaint);
}

@monsieurtanuki
Copy link
Contributor Author

As you see, the impact would be limited on crop_image, and that would look like this:
Screenshot_1717091892

@monsieurtanuki
Copy link
Contributor Author

Working on the subject. cf. openfoodfacts/smooth-app#5301
It looks like the only change would be an additional optional CustomPainter in getCroppedBitmap.

@deakjahn
Copy link
Owner

I can't yet see how that would be used. I mean, croppedBitmap() is purely a convenience function that's in the package mostly to avoid people always asking the first question of 'but what do I do with the crop rectangle when done'? The package itself doesn't use it and you're never forced to use the function from the package, you can process your crop rectangle any way you see fit. So why would it be advantageous to integrate it into the cropper?

@monsieurtanuki
Copy link
Contributor Author

The fact that I need this feature in a concrete use-case shows that i's not just a theoretical "what if / just in case" feature request.

You're right if you're talking about a fixed crop widget: a Widget with an input file, a crop grid and a "save cropped image" button. No need to change that.

But it's already a bit different now, with the controller and separate "rotate" widgets: developers can use their own buttons and their own icons, put them where they want, or even not display any "rotate" buttons at all.

If we're rather talking about a crop toolkit we keep the CropImage as a turnkey solution, but provide flexibility.

@deakjahn
Copy link
Owner

deakjahn commented Jun 2, 2024

If you think that it's only an added callback, sure, go ahead, try it.

@monsieurtanuki
Copy link
Contributor Author

Thank you @deakjahn! I haven't finished my code and tests yet, but on the crop_image side that will be just a CustomPainter? parameter here and there.
I keep you posted.

@deakjahn
Copy link
Owner

deakjahn commented Jun 5, 2024

Implemented by #53.

@deakjahn deakjahn closed this as completed Jun 5, 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

2 participants