6

I want to maintain the quality(size) of the image being uploaded. The options being used for this is

const options = { quality:1, maxWidth: 500, maxHeight: 500, allowsEditing: false, storageOptions: { skipBackup: true } }

Prakash
  • 396
  • 1
  • 6
  • 23

2 Answers2

9

Remove the maxWidth and maxHeight from the options. That is what is reducing the size of the image.

You can see more of the options the api allows here https://github.com/react-native-community/react-native-image-picker/

Andrew
  • 26,706
  • 9
  • 85
  • 101
  • hi, i have the opposite problem, the image is not be resized when i put maxWidth and maxHeight in the options – Mikha Matta Mar 29 '22 at 10:14
  • 1
    The resize options only work for downsizing the image, as you can see [here](https://github.com/react-native-image-picker/react-native-image-picker/blob/53271c3af8d050c3a59241b0847f9130fa2c8939/ios/ImagePickerUtils.m#L145) in the code `if (image.size.width <= maxWidth && image.size.height <= maxHeight) { return image} ` so if you image is smaller than the maxWidth and the maxHeight then it will just return the image without any changes. If you image is bigger than the max and it is not being downsized, then I suggest you open an issue with the repo's maintainer. – Andrew Mar 29 '22 at 12:29
0
    let options = {
      quality:1, 
      allowsEditing: false,
      noData:true, 
      storageOptions: { skipBackup: true }}
    launchCamera(options, response => {
      if (response.didCancel) {
        console.log('User cancelled image picker');
      } else if (response.error) {
        console.log('ImagePicker Error:',response.error);
      } else {
        handleUploadPhoto(response.assets[0]);
      }
    });
David Leuliette
  • 1,595
  • 18
  • 26