xclud / flutter_crop

Crop any widget/image in Android, iOS, Web and Desktop with fancy and customizable UI, in pure Dart code.
https://pub.dev/packages/crop
MIT License
257 stars 84 forks source link

Total width and height #29

Closed michaldev closed 3 years ago

michaldev commented 4 years ago

Hi. Can I set the total output width and height of my Image? I would like to get Image (example) in 800x800 size independent from the image inside. Too if the image inside is smaller than 800x800.

xclud commented 4 years ago

Hi @michaldev, You can set the aspect ratio to 1 (800 / 800 = 1) and then resize the output image to 800x800. Here is a good package for image resizing: https://pub.dev/packages/image

michaldev commented 4 years ago

No, I can't because If Image is 400x200 (expected 800x800) I would like set where the image in image should be, and user should choose - image resize, movement or resize and movement.

xclud commented 4 years ago

If the input aspect ratio is not equal to the desired output aspect ratio, it's user's job to choose where in the image to be selected.

michaldev commented 4 years ago

Yes, I know. But I would like positioning image in crop-viewport when Image is smaller than target and if I don't want scale it. Like this: 2

xclud commented 4 years ago

Did you try Image widget with fit: BoxFit.cover?

michaldev commented 4 years ago

Yes. Image always return to center. Independent from fit parameter.

xclud commented 4 years ago

How about putting the Image into a FittedBox?

michaldev commented 4 years ago

I’ve used your example.

xclud commented 4 years ago

Please try FittedBox and let me know.

michaldev commented 4 years ago

I've used that, but without effect.

https://vimeo.com/447069518

Code:

Crop(
                controller: controller,
                shape: shape,
                child: FittedBox(
                  child: Image.network(
                    'https://upload.wikimedia.org/wikipedia/commons/1/1b/Square_200x200.png',
                    fit: BoxFit.cover,
                  ),
                ), 
                foreground: IgnorePointer(
                  child: Container(
                    alignment: Alignment.bottomRight,
                    child: Text(
                      'Foreground Object',
                      style: TextStyle(color: Colors.red),
                    ),
                  ),
                ),
                helper: shape == CropShape.box
                    ? Container(
                        decoration: BoxDecoration(
                          border: Border.all(color: Colors.white, width: 2),
                        ),
                      )
                    : null,
              ),
xclud commented 3 years ago

I close this issue for #27. Please feel free to continue this discussion there.