Skip to content

image_picker plugin ignores width/height of the resulting image in iOS #40831

@owops

Description

@owops

Image picker plugin cause error width and height in scaled images.

File imageFile = await ImagePicker.pickImage(
      source: ImageSource.camera,
      maxWidth: 800,
);

image source pixel:
3024 × 4032

image scale result pixel:
1066 × 800

Reason:
In image picker plugin, use

UIImage *imageToScale = [UIImage imageWithCGImage:image.CGImage
                                              scale:1
                                        orientation:UIImageOrientationUp];

to change Image rotation to UIImageOrientationUp

but forget to swap width/height result

if([image imageOrientation] == UIImageOrientationLeft
    || [image imageOrientation] == UIImageOrientationRight
    || [image imageOrientation] == UIImageOrientationLeftMirrored
    || [image imageOrientation] == UIImageOrientationRightMirrored) {
    double temp = width;
    width = height;
    height = temp;
}

these codes will fix this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions