7.1.2 • Published 1 month ago

react-native-image-picker v7.1.2

Weekly downloads
102,067
License
MIT
Repository
github
Last release
1 month ago

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:

RequirementKey
Select image/video from photosNSPhotoLibraryUsageDescription
Capture ImageNSCameraUsageDescription
Capture VideoNSCameraUsageDescription & 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.

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

OptioniOSAndroidWebDescription
mediaTypeOKOKOKphoto or video or mixed(launchCamera on Android does not support 'mixed'). Web only supports 'photo' for now.
maxWidthOKOKNOTo resize the image.
maxHeightOKOKNOTo resize the image.
videoQualityOKOKNOlow, medium, or high on iOS, low or high on Android.
durationLimitOKOKNOVideo max duration (in seconds).
qualityOKOKNO0 to 1, photos.
cameraTypeOKOKNO'back' or 'front' (May not be supported in few android devices).
includeBase64OKOKOKIf true, creates base64 string of the image (Avoid using on large image files due to performance).
includeExtraOKOKNOIf true, will include extra data which requires library permissions to be requested (i.e. exif data).
saveToPhotosOKOKNO(Boolean) Only for launchCamera, saves the image/video file captured to public photo.
selectionLimitOKOKOKSupports providing any integer value. Use 0 to allow any number of files on iOS version >= 14 & Android version >= 13. Default is 1.
presentationStyleOKNONOControls how the picker is presented. currentContext, pageSheet, fullScreen, formSheet, popover, overFullScreen, overCurrentContext. Default is currentContext.
formatAsMp4OKNONOConverts the selected video to MP4 (iOS Only).
assetRepresentationModeOKNONOA mode that determines which representation to use if an asset contains more than one. Possible values: 'auto', 'current', 'compatible'. Default is 'auto'.

The Response Object

keyiOSAndroidWebDescription
didCancelOKOKOKtrue if the user cancelled the process
errorCodeOKOKOKCheck ErrorCode for all error codes
errorMessageOKOKOKDescription of the error, use it for debug purpose only
assetsOKOKOKArray of the selected media, refer to Asset Object

Asset Object

keyiOSAndroidWebPhoto/VideoRequires PermissionsDescription
base64OKOKOKPHOTO ONLYNOThe base64 string of the image (photos only)
uriOKOKOKBOTHNOThe 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.
originalPathNOOKNOBOTHNOThe original file path.
widthOKOKOKBOTHNOAsset dimensions
heightOKOKOKBOTHNOAsset dimensions
fileSizeOKOKNOBOTHNOThe file size
typeOKOKNOBOTHNOThe file type
fileNameOKOKNOBOTHNOThe file name
durationOKOKNOVIDEO ONLYNOThe selected video duration in seconds
bitrate---OKNOVIDEO ONLYNOThe average bitrate (in bits/sec) of the selected video, if available. (Android only)
timestampOKOKNOBOTHYESTimestamp of the asset. Only included if 'includeExtra' is true
idOKOKNOBOTHYESlocal 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

CodeDescription
camera_unavailableCamera not available on device
permissionPermission not satisfied
othersOther errors (check errorMessage for description)

License

MIT

@neur0base/app-sdk@dededeck/dede-tabletreact-native-local-video-trimmersensesocialbuilders-uimiot-workspacehipposdk@snooper/corereact-native-custom-components-dwsi-invest-wealth@bravemaster619/interview-uimira-test-3tinh-mirareact-native-isw-starter@doggoapp/doggo-mobile-components-tsairasia1222dictionarymacmillanrewards-test@infinitebrahmanuniverse/nolb-react-native-itelemed-ui-layerordering-ui-react-native@everything-registry/sub-chunk-2580inspectionmodulehyeonminhipporeactsdkhelmet-adherence-awtbakarin-bun-appvih-messengerordering-ui-native-releaseordering-ui-native-ubanku-releasenpm-demo-baahubali-showupnative-cmos-image-pickerocr1onboarding-widget-usogienchatoperationnpmmateusapp-chatbot-react-nativelearn-how-to-publish-to-registrylikeminds_chat_reactnative_integration_betamost_powerfull_react_native_ui_libmodule-native-basemodule-native-gbmodule-native-svmodule-native-testnetforce_ui_nativeprixa-telemedicine-rn-sdkpoket-app-testtemplate43syrow-sdkstorybook-compostorybook-componentstheo-prixa-sdk-testundigitals-chatreact-native-cgws-supportreact-native-awesome-chatreact-native-fm-formreact-native-form-builder-proreact-native-diaozhao-commonreact-native-dynamic-formsreact-native-expo-router-templatereact-native-image-picker-resizerreact-native-image-upload-pluginreact-native-barcode-scannersreact-native-get-mediareact-native-genix-image-uploaderreact-native-in-app-galleryreact-native-interactive-avatarreact-native-template-cprntemplatereact-native-template-rnbasicreact-native-video-trim-pickerreact-native-videoeditor-iosreact-native-yiyibasereact-native-upload-galleryreact-native-usefulappreact-native-union-betareact-native-ui-xepreact-native-vih-messengersreact-native-template-template36react-native-tempssreact-native-test1sheshamobile.coreship2myid-native-packagerunner-camp-shoprunnercamp-shopsaas-plat-nativesmcinsurancestablex-sdkrecytrackrewards-test3react-native-shakebug-testingreact-native-osd-formreact-native-pixel-feedbacksreact-native-1appreact-native-1app-themereact-native-chunkyreact-native-chunky-contreact-native-cxgenie-chatreact-native-ocr-vesoreact-native-kyc-verificationreact-native-matrix
7.1.2

1 month ago

7.1.1

1 month ago

7.0.3

5 months ago

7.0.2

6 months ago

7.0.1

7 months ago

7.1.0

5 months ago

6.0.1

10 months ago

6.0.0

10 months ago

5.4.2

11 months ago

5.4.1

11 months ago

5.4.0

11 months ago

7.0.0

8 months ago

5.5.0

10 months ago

5.6.1

8 months ago

5.6.0

10 months ago

5.7.0

8 months ago

5.0.2

1 year ago

5.0.1

1 year ago

5.1.0

1 year ago

5.2.0

1 year ago

5.3.1

1 year ago

5.3.0

1 year ago

5.0.0

1 year ago

4.10.1

1 year ago

4.10.2

1 year ago

4.10.3

1 year ago

4.9.0

2 years ago

4.10.0

2 years ago

4.8.5

2 years ago

4.8.4

2 years ago

4.8.1

2 years ago

4.8.0

2 years ago

4.8.3

2 years ago

4.8.2

2 years ago

4.7.4

2 years ago

4.4.1

2 years ago

4.4.0

2 years ago

4.4.2

2 years ago

4.7.0

2 years ago

4.7.2

2 years ago

4.7.1

2 years ago

4.7.3

2 years ago

4.6.1

2 years ago

4.6.0

2 years ago

4.5.0

2 years ago

4.3.0

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.2

3 years ago

4.1.0

3 years ago

4.1.1

3 years ago

4.0.6

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

3.8.0

3 years ago

3.8.1

3 years ago

3.7.0

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.3.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

2.4.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

3.0.0-vnext.4

3 years ago

3.0.0-vnext.3

3 years ago

3.0.0-vnext.2

3 years ago

3.0.0-vnext.1

3 years ago

3.0.0-vnext.0

3 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

0.28.1

5 years ago

0.28.0

5 years ago

0.27.2

5 years ago

0.27.1

6 years ago

0.27.0

6 years ago

0.26.10

6 years ago

0.26.9

6 years ago

0.26.8

6 years ago

0.26.7

7 years ago

0.26.6

7 years ago

0.26.5

7 years ago

0.26.4

7 years ago

0.26.3

7 years ago

0.26.2

7 years ago

0.26.1

7 years ago

0.26.0

7 years ago

0.25.7

7 years ago

0.25.6

7 years ago

0.25.5

7 years ago

0.25.4

7 years ago

0.25.3

7 years ago

0.25.1

7 years ago

0.25.0

7 years ago

0.24.1

7 years ago

0.24.0

7 years ago

0.23.0

7 years ago

0.22.14

7 years ago

0.22.13

7 years ago

0.22.12

8 years ago

0.22.11

8 years ago

0.22.10

8 years ago

0.22.9

8 years ago

0.22.8

8 years ago

0.22.7

8 years ago

0.22.6

8 years ago

0.22.5

8 years ago

0.22.4

8 years ago

0.22.3

8 years ago

0.22.2

8 years ago

0.22.1

8 years ago

0.22.0

8 years ago

0.21.5

8 years ago

0.21.4

8 years ago

0.21.3

8 years ago

0.21.2

8 years ago

0.21.1

8 years ago

0.21.0

8 years ago

0.20.2

8 years ago

0.20.1

8 years ago

0.20.0

8 years ago

0.19.7

8 years ago

0.19.6

8 years ago

0.19.5

8 years ago

0.19.4

8 years ago

0.19.3

8 years ago

0.19.2

8 years ago

0.19.1

8 years ago

0.19.0

8 years ago

0.18.17

8 years ago

0.18.16

8 years ago

0.18.15

8 years ago

0.18.14

8 years ago

0.18.13

8 years ago

0.18.12

8 years ago

0.18.11

8 years ago

0.18.10

8 years ago

0.18.9

8 years ago

0.18.8

8 years ago

0.18.7

8 years ago

0.18.6

8 years ago

0.18.5

8 years ago

0.18.4

8 years ago

0.18.3

8 years ago

0.18.2

8 years ago

0.18.1

8 years ago

0.18.0

8 years ago

0.17.0

8 years ago

0.16.2

8 years ago

0.16.1

8 years ago

0.16.0

8 years ago

0.15.0

8 years ago

0.14.3

8 years ago

0.14.2

8 years ago

0.14.1

8 years ago

0.14.0

8 years ago

0.13.6

8 years ago

0.13.5

8 years ago

0.13.4

8 years ago

0.13.3

8 years ago

0.13.2

8 years ago

0.13.1

8 years ago

0.13.0

8 years ago

0.12.4

8 years ago

0.12.2

8 years ago

0.12.1

8 years ago

0.12.0

8 years ago

0.11.3

8 years ago

0.11.2

8 years ago

0.11.1

8 years ago

0.10.0

8 years ago

0.9.0

8 years ago

0.8.0

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago