react-native-image-picker vs react-native-image-crop-picker vs react-native-camera
React Native Image Handling Libraries Comparison
1 Year
react-native-image-pickerreact-native-image-crop-pickerreact-native-cameraSimilar Packages:
What's React Native Image Handling Libraries?

These libraries provide essential functionalities for handling images in React Native applications, each with unique features tailored for specific use cases. They enhance the user experience by enabling camera access, image selection, and cropping capabilities, which are crucial for applications that rely on user-generated content. Understanding their individual strengths helps developers choose the right tool for their specific needs, ensuring efficient image management and manipulation within their apps.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-native-image-picker395,5478,517188 kB30619 hours agoMIT
react-native-image-crop-picker165,3136,1912.17 MB868a month agoMIT
react-native-camera84,1529,642-1443 years agoMIT AND Apache-2.0 AND BSD-3-Clause
Feature Comparison: react-native-image-picker vs react-native-image-crop-picker vs react-native-camera

Camera Functionality

  • react-native-image-picker:

    react-native-image-picker offers basic camera functionality, allowing users to take photos directly from the camera or select images from the gallery. However, it lacks advanced features like barcode scanning or face detection.

  • react-native-image-crop-picker:

    react-native-image-crop-picker does not provide direct camera functionalities but allows users to take photos using the device's camera when selecting images. Its primary focus is on image cropping and selection rather than camera control.

  • react-native-camera:

    react-native-camera provides extensive camera functionalities, allowing developers to implement features like photo and video capturing, barcode scanning, and even face detection. It supports various camera types and configurations, making it versatile for different use cases.

Image Cropping

  • react-native-image-picker:

    react-native-image-picker does not support image cropping natively. Users can select images, but any cropping functionality must be implemented separately.

  • react-native-image-crop-picker:

    react-native-image-crop-picker excels in image cropping, providing an intuitive interface for users to crop images after selection. It supports various aspect ratios and cropping styles, enhancing the overall user experience.

  • react-native-camera:

    react-native-camera does not include built-in image cropping features. Developers need to implement additional libraries or custom solutions for cropping images after capturing them.

Ease of Use

  • react-native-image-picker:

    react-native-image-picker is lightweight and easy to use, making it an excellent choice for developers looking for a quick solution for image selection without complex configurations.

  • react-native-image-crop-picker:

    react-native-image-crop-picker is user-friendly and straightforward to implement, especially for image selection and cropping. Its API is designed to be intuitive, making it easier for developers to integrate into their applications.

  • react-native-camera:

    react-native-camera has a steeper learning curve due to its extensive features and configuration options. Developers may need to invest time in understanding the API and implementing advanced functionalities effectively.

Performance

  • react-native-image-picker:

    react-native-image-picker is lightweight and performs well for basic image selection tasks. It is generally efficient, but performance can be impacted by the number of images or size of the images being processed.

  • react-native-image-crop-picker:

    react-native-image-crop-picker is optimized for performance during image selection and cropping, ensuring a smooth user experience even with high-resolution images. However, performance may vary based on the device's capabilities.

  • react-native-camera:

    react-native-camera can be resource-intensive, especially when using advanced features like video recording and real-time processing. Developers should optimize performance by managing camera settings and resource usage effectively.

Community Support

  • react-native-image-picker:

    react-native-image-picker has a large user base and community support, making it easy to find solutions and examples. However, it may not have as many advanced features or updates compared to the other two libraries.

  • react-native-image-crop-picker:

    react-native-image-crop-picker also enjoys good community support, with active contributions and documentation. Developers can find helpful resources and examples to assist in implementation.

  • react-native-camera:

    react-native-camera has a strong community and is actively maintained, providing a wealth of resources, documentation, and support for developers. This makes it easier to find solutions to common issues and stay updated with new features.

How to Choose: react-native-image-picker vs react-native-image-crop-picker vs react-native-camera
  • react-native-image-picker:

    Choose react-native-image-picker for straightforward image selection from the device's gallery or camera. It is lightweight and easy to implement, making it suitable for applications that need basic image picking functionalities without additional features.

  • react-native-image-crop-picker:

    Choose react-native-image-crop-picker if your application requires robust image cropping and selection features. It allows users to select images from the gallery or take new photos, with built-in cropping capabilities that enhance user experience and image quality.

  • react-native-camera:

    Choose react-native-camera if you need comprehensive camera functionalities, including capturing photos, recording videos, and scanning barcodes. It is ideal for applications that require direct camera access and advanced features like face detection and barcode scanning.

README for react-native-image-picker

react-native-image-picker 🎆

A React Native module that allows you to select a photo/video from the device library or camera.

npm downloads npm package License

Installation

yarn add react-native-image-picker

New Architecture

To take advantage of the new architecture run-

iOS

RCT_NEW_ARCH_ENABLED=1 npx pod-install ios

Android

Set newArchEnabled to true inside android/gradle.properties

Pre-Fabric (AKA not using the new architecture)

npx pod-install ios

Post-install Steps

iOS

Add the appropriate keys to your Info.plist depending on your requirement:

| Requirement | Key | | ------------------------------ | --------------------------------------------------- | | Select image/video from photos | NSPhotoLibraryUsageDescription | | Capture Image | NSCameraUsageDescription | | Capture Video | NSCameraUsageDescription & NSMicrophoneUsageDescription |

Android

No permissions required (saveToPhotos requires permission check).

Note: This library does not require Manifest.permission.CAMERA, if your app declares as using this permission in manifest then you have to obtain the permission before using launchCamera.

Targeting Android API Levels Below 30

If your app's minSdkVersion is set to below 30 and it does not already include or depend on androidx.activity:activity:1.9.+ or a newer version, you'll need to add the following line to the dependencies section of your app/build.gradle file to ensure support for the backported AndroidX Photo Picker:

dependencies {
    ...
    implementation("androidx.activity:activity:1.9.+")
    ...
}

Additionally, you may need to update your AndroidManifest.xml to trigger the installation of the backported Photo Picker. For reference, you can check the example app's configuration in example/android/app/src/main/AndroidManifest.xml and example/android/app/build.gradle.

For more details, consult the Android documentation on AndroidX Photo Picker: https://developer.android.com/training/data-storage/shared/photopicker

API Reference

Methods

import {launchCamera, launchImageLibrary} from 'react-native-image-picker';

launchCamera()

Launch camera to take photo or video.

launchCamera(options?, callback);

// You can also use as a promise without 'callback':
const result = await launchCamera(options?);

See Options for further information on options.

The callback will be called with a response object, refer to The Response Object.

launchImageLibrary

Launch gallery to pick image or video.

launchImageLibrary(options?, callback)

// You can also use as a promise without 'callback':
const result = await launchImageLibrary(options?);

See Options for further information on options.

The callback will be called with a response object, refer to The Response Object.

Options

| Option | iOS | Android | Web | Description | | ----------------------- | --- | ------- | --- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | mediaType | OK | OK | OK | photo or video or mixed(launchCamera on Android does not support 'mixed'). Web only supports 'photo' for now. | | maxWidth | OK | OK | NO | To resize the image. | | maxHeight | OK | OK | NO | To resize the image. | | videoQuality | OK | OK | NO | low, medium, or high on iOS, low or high on Android. | | durationLimit | OK | OK | NO | Video max duration (in seconds). | | quality | OK | OK | NO | 0 to 1, photos. | | conversionQuality | NO | OK | NO | For conversion from HEIC/HEIF to JPEG, 0 to 1. Default is 0.92 | | cameraType | OK | OK | NO | 'back' or 'front' (May not be supported in few android devices). | | includeBase64 | OK | OK | OK | If true, creates base64 string of the image (Avoid using on large image files due to performance). | | includeExtra | OK | OK | NO | If true, will include extra data which requires library permissions to be requested (i.e. exif data). | | saveToPhotos | OK | OK | NO | (Boolean) Only for launchCamera, saves the image/video file captured to public photo. | | selectionLimit | OK | OK | OK | Supports providing any integer value. Use 0 to allow any number of files on iOS version >= 14 & Android version >= 13. Default is 1. | | presentationStyle | OK | NO | NO | Controls how the picker is presented. currentContext, pageSheet, fullScreen, formSheet, popover, overFullScreen, overCurrentContext. Default is currentContext. | | formatAsMp4 | OK | NO | NO | Converts the selected video to MP4 (iOS Only). | | assetRepresentationMode | OK | OK | NO | A mode that determines which representation to use if an asset contains more than one on iOS or disables HEIC/HEIF to JPEG conversion on Android if set to 'current'. Possible values: 'auto', 'current', 'compatible'. Default is 'auto'. |

The Response Object

| key | iOS | Android | Web | Description | | ------------ | --- | ------- | --- | ------------------------------------------------------------------- | | didCancel | OK | OK | OK | true if the user cancelled the process | | errorCode | OK | OK | OK | Check ErrorCode for all error codes | | errorMessage | OK | OK | OK | Description of the error, use it for debug purpose only | | assets | OK | OK | OK | Array of the selected media, refer to Asset Object |

Asset Object

| key | iOS | Android | Web | Photo/Video | Requires Permissions | Description | | --------- | --- | ------- | --- | ----------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | base64 | OK | OK | OK | PHOTO ONLY | NO | The base64 string of the image (photos only) | | uri | OK | OK | OK | BOTH | NO | The file uri in app specific cache storage. Except when picking video from Android gallery where you will get read only content uri, to get file uri in this case copy the file to app specific storage using any react-native library. For web it uses the base64 as uri. | | originalPath | NO | OK | NO | BOTH | NO | The original file path. | | width | OK | OK | OK | BOTH | NO | Asset dimensions | | height | OK | OK | OK | BOTH | NO | Asset dimensions | | fileSize | OK | OK | NO | BOTH | NO | The file size | | type | OK | OK | NO | BOTH | NO | The file type | | fileName | OK | OK | NO | BOTH | NO | The file name | | duration | OK | OK | NO | VIDEO ONLY | NO | The selected video duration in seconds | | bitrate | --- | OK | NO | VIDEO ONLY | NO | The average bitrate (in bits/sec) of the selected video, if available. (Android only) | | timestamp | OK | OK | NO | BOTH | YES | Timestamp of the asset. Only included if 'includeExtra' is true | | id | OK | OK | NO | BOTH | YES | local identifier of the photo or video. On Android, this is the same as fileName |

Note on file storage

Image/video captured via camera will be stored in temporary folder allowing it to be deleted any time, so don't expect it to persist. Use saveToPhotos: true (default is false) to save the file in the public photos. saveToPhotos requires WRITE_EXTERNAL_STORAGE permission on Android 28 and below (The permission has to obtained by the App manually as the library does not handle that).

For web, this doesn't work.

ErrorCode

| Code | Description | | ------------------ | ------------------------------------------------- | | camera_unavailable | Camera not available on device | | permission | Permission not satisfied | | others | Other errors (check errorMessage for description) |

License

MIT