0

Photos captured via camera are too large for efficient upload and download in React native. Also i am facing issues in displaying images in latest iPhone models like X, XS, XSMax and XR

I am using the npm package react-native-image-picker. Though it works well but i cannot resize the image which is the main concern for me!!

The result expected: I should be able to resize the image and upload it to server as well as view it in all mobile phones.

The actual result: I cannot resize the image and also cannot view the image on iPhone X and other latest iPhone models.

Aarsh Oza
  • 164
  • 1
  • 4
  • 19

1 Answers1

1

You can use expo-image-manipulator to compress images.

If you use expo it is pre installed and you can import it directly:

import { ImageManipulator } from 'expo';

const manipResult = await ImageManipulator.manipulateAsync(
    image,
    [],
    { compress: 0.5 }
);

Otherwise you must install it as a standalone package and use it like this:

import * as ImageManipulator from 'expo-image-manipulator';

const manipResult = await ImageManipulator.manipulateAsync(
    image,
    [],
    { compress: 0.5 }
);

compress must be value in range 0.0 - 1.0 specifying compression level of the result image. 1 means no compression (highest quality) and 0 the highest compression (lowest quality).

For more info see the Image Manipulator docs