Skip to content

[image_picker]: maxHeight and maxWidth not working as expected #88901

@guihackmann

Description

@guihackmann

I realized today the behavior of maxHeight and maxWidth is different in the following 2 scenarios.

Assumption: Image original width is 1125 and height 2000.

Scenario 1 (works as expected)
_picker.pickImage(source: Picker.ImageSource.gallery, maxHeight: 1100, maxWidth: 1100);
Result:
Image gets the following Size: Height: 1100 (as limited above), Width: 618 (adjusted proportionally, perfect)

Scenario 2 (doesn't work as expected)
_picker.pickImage(source: Picker.ImageSource.gallery, maxHeight: 1200, maxWidth: 1200);
Result:
Image gets the size of the original image: Height: 2000 (beyond the limit I set above), Width: 1125

I notice that this happens when the limit (maxHeight or maxWidth) is above the original images size. So in scenario 2, as I set maxWidth 1200, but the original image has less (1125), it allows height go beyond maxHeight.

Steps to Reproduce

Pick an image from gallery using image_picker - _picker.pickImage(source: Picker.ImageSource.gallery, maxHeight: 1200, maxWidth: 1200), using an image that has a width or height above the maxWidth or maxHeight.

Expected results:
On scenario 2, I would expect the image to get Height of 1200 (as per maxHeight), and Width of 675 (proportional equivalent)

Actual results:
On scenario 2, I got a Height above the maxHeight (2000) and width of 1125.

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions