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

Total width and height #29

Closed
michaldev opened this issue Aug 11, 2020 · 11 comments
Closed

Total width and height #29

michaldev opened this issue Aug 11, 2020 · 11 comments

Comments

@michaldev
Copy link

michaldev commented Aug 11, 2020

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
Copy link
Owner

xclud commented Aug 11, 2020

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
Copy link
Author

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
Copy link
Owner

xclud commented Aug 11, 2020

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
Copy link
Author

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
Copy link
Owner

xclud commented Aug 11, 2020

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

@michaldev
Copy link
Author

michaldev commented Aug 11, 2020

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

@xclud
Copy link
Owner

xclud commented Aug 11, 2020

How about putting the Image into a FittedBox?

@michaldev
Copy link
Author

I’ve used your example.

@xclud
Copy link
Owner

xclud commented Aug 11, 2020

Please try FittedBox and let me know.

@michaldev
Copy link
Author

michaldev commented Aug 12, 2020

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
Copy link
Owner

xclud commented Nov 25, 2020

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

@xclud xclud closed this as completed Nov 25, 2020
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