The imagePicker allways crop as square?

#1

I did an app in ios and I was able to take a picture or selected from the library and crop it rectangular with an aspectRatio that I wish. Using EXPO imagePicker, I can’t get an portrait image, is there a way to get rectangle portrait images on the ios simulator with Expo image picker?

#2

What are you passing to this parameter?

https://docs.expo.io/versions/latest/sdk/imagepicker.html#aspect-array--an-array-with-two-entries-x-y-specifying-the-aspect-ratio-to-maintain-if-the-user-is-allowed-to-edit-the-image-by-passing-allowsediting-true-this-is-only-applicable-on-android-since-on-ios-the-crop-rectangle-is-always-a-square

#3

_pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
allowsEditing: true,
aspect: [4, 3],
});
console.log(result.uri);

if (!result.cancelled) {
  this.setState({ image: result.uri });
}

};

I did play with the aspect ratio but as it said in your link for ios it does not work but I want a portrait layout and cant find any documentation.

#4

You might need to resize the image on your own.

For that, you’d need to drop to the level of ExpoKit and use this react-native library: https://github.com/bamlab/react-native-image-resizer