Cropping image in camera preview with Expo Camera

I have implemented Expo’s Camera API successfully and it works great for my implementation, however there is a certain piece of functionality that I still require and am not sure if it is supported by this Camera API.

I need to be able to define a cropping zone in the camera preview before taking the picture and have the resulting picture only be from the defined cropping zone.

If there is not a solution like this in place is it possible to crop an image from takePictureAsync() after the full size image has been snapped? If so I could just absolutely position a cropping guide on the camera preview window and crop the image to match this guide after the picture has been taken.

Thanks in advance!

I don’t believe it’s possible to do within the camera API - essentially the full data that hits the sensor is exposed via the OS-level API’s.

It IS possible to crop the resulting image though; https://github.com/ivpusic/react-native-image-crop-picker

This assumes you know the file path to the saved image. I’ve not used the camera API in any projects yet, but I’m sure that Expo’s implementation will return the path to the image.

You can also use ImageManipulator within Expo: https://docs.expo.io/versions/v28.0.0/sdk/imagemanipulator

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.