Search code examples
react-nativeexpoexpo-camera

How to set the quality of the picture when using the expo camera?


I'm using Expo (React Native) and Express.js (Node.js) and I'm trying to develop an app that can take pictures and store them on the server.

So far, I have completed all this, but I want to make sure the server isn't overrun from really high quality photos that smartphones can take nowadays.

I tried to look at the documentation for the Expo camera and there is a section for quality, but it's under the CameraPictureOptions which is under the Types section.

I'm not 100% sure how to access these in the code as they don't offer any examples. Really all I need is an example of how to edit the quality of the photos that the Expo camera takes.


Solution

  • You can set the expo-camera captured picture quality by using quality: 0.5, in the takePictureAsync options

     const photo = await cameraRef.takePictureAsync({
        quality: 0.5, // Adjust this value (0.0 - 1.0) for picture quality
        skipProcessing: true, // Set to true to skip processing
     });
    

    skipProcessing is not related to the question but this to faster the camera capture