Home > OS >  In React Native / Expo, is there any way to save a specific part of an image?
In React Native / Expo, is there any way to save a specific part of an image?

Time:05-05

From some research, I've figured out that expo libraries like takePicturesAsync() are able to take a picture and save it to the app's cache. However, the default state for libraries like these is to save the whole image. Is there any way for me to save a specific part of the image (e.g. the 2500 pixels at the center of the screen)?

Thanks!

CodePudding user response:

You can use the onPictureSaved event to grab & manipulate the image.

 takePicture = () => {
      if (this.camera) {
          this.camera.takePictureAsync({ onPictureSaved: this.onPictureSaved });
      }
   };

  onPictureSaved = photo => {
      console.log(photo);
  } 
  • Related