react-native-image-picker (2024)

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

react-native-image-picker (1) react-native-image-picker (2)

Make sure you're reading the doc applicable to your version, for example if your using version 3.8.0 go to tag 3.8.0 and read those docs. This doc is always that of main branch.

Also read version release notes for any breaking changes especially if you're updating the major version.

yarn add react-native-image-picker# RN >= 0.60cd ios && pod install# RN < 0.60react-native link react-native-image-picker

Post-install Steps

iOS

Add the appropriate keys to your Info.plist,

If you are allowing user to select image/video from photos, add NSPhotoLibraryUsageDescription.

If you are allowing user to capture image add NSCameraUsageDescription key also.

If you are allowing user to capture video add NSCameraUsageDescription add NSMicrophoneUsageDescription key also.

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.

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

OptioniOSAndroidDescription
mediaTypeOKOK'photo' or 'video' or 'mixed'(mixed supported only for launchImageLibrary, to pick an photo or video)
maxWidthOKOKTo resize the image
maxHeightOKOKTo resize the image
videoQualityOKOK'low', 'medium', or 'high' on iOS, 'low' or 'high' on Android
durationLimitOKOKVideo max duration in seconds
qualityOKOK0 to 1, photos
cameraTypeOKOK'back' or 'front'. May not be supported in few android devices
includeBase64OKOKIf true, creates base64 string of the image (Avoid using on large image files due to performance)
includeExtraOKOKIf true, will include extra data which requires library permissions to be requested (i.e. exif data)
saveToPhotosOKOK(Boolean) Only for launchCamera, saves the image/video file captured to public photo
selectionLimitOKOKDefault is 1, use 0 to allow any number of files. Only iOS version >= 14 support 0 and also it supports providing any integer value
presentationStyleOKNOControls how the picker is presented. 'pageSheet', 'fullScreen', 'pageSheet', 'formSheet', 'popover', 'overFullScreen', 'overCurrentContext'. Default is 'currentContext'

The Response Object

keyiOSAndroidDescription
didCancelOKOKtrue if the user cancelled the process
errorCodeOKOKCheck ErrorCode for all error codes
errorMessageOKOKDescription of the error, use it for debug purpose only
assetsOKOKArray of the selected media, refer to Asset Object

Asset Object

keyiOSAndroidPhoto/VideoRequires PermissionsDescription
base64OKOKPHOTO ONLYNOThe base64 string of the image (photos only)
uriOKOKBOTHNOThe 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
widthOKOKBOTHNOAsset dimensions
heightOKOKBOTHNOAsset dimensions
fileSizeOKOKBOTHNOThe file size
typeOKOKBOTHNOThe file type
fileNameOKOKBOTHNOThe file name
durationOKOKVIDEO ONLYNOThe selected video duration in seconds
bitrate---OKVIDEO ONLYNOThe average bitrate (in bits/sec) of the selected video, if available. (Android only)
timestampOKOKBOTHYESTimestamp of the asset. Only included if 'includeExtra' is true
idOKOKBOTHYESlocal 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 so will 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 (You have to obtain the permission, the library does not).

ErrorCode

CodeDescription
camera_unavailablecamera not available on device
permissionPermission not satisfied
othersother errors (check errorMessage for description)

License

MIT

react-native-image-picker (2024)
Top Articles
Best Crypto Staking Platforms & Reward Rates for 2024
Personal banking from U.S. Bank
Pollen Count Centreville Va
Woodward Avenue (M-1) - Automotive Heritage Trail - National Scenic Byway Foundation
It's Official: Sabrina Carpenter's Bangs Are Taking Over TikTok
Uhauldealer.com Login Page
Fat Hog Prices Today
Dte Outage Map Woodhaven
Chatiw.ib
Voorraad - Foodtrailers
Khatrimaza Movies
Palace Pizza Joplin
New Day Usa Blonde Spokeswoman 2022
Ogeechee Tech Blackboard
Rainfall Map Oklahoma
Power Outage Map Albany Ny
Ukraine-Russia war: Latest updates
Brutál jó vegán torta! – Kókusz-málna-csoki trió
Flights To Frankfort Kentucky
Bowie Tx Craigslist
Spergo Net Worth 2022
Spider-Man: Across The Spider-Verse Showtimes Near Marcus Bay Park Cinema
Music Go Round Music Store
ABCproxy | World-Leading Provider of Residential IP Proxies
Cbssports Rankings
Nz Herald Obituary Notices
Routing Number For Radiant Credit Union
Zillow Group Stock Price | ZG Stock Quote, News, and History | Markets Insider
Does Hunter Schafer Have A Dick
Why Are Fuel Leaks A Problem Aceable
Craigslist List Albuquerque: Your Ultimate Guide to Buying, Selling, and Finding Everything - First Republic Craigslist
Craigslist Pasco Kennewick Richland Washington
Summoners War Update Notes
Movies - EPIC Theatres
Why comparing against exchange rates from Google is wrong
Mg Char Grill
Most popular Indian web series of 2022 (so far) as per IMDb: Rocket Boys, Panchayat, Mai in top 10
Walter King Tut Johnson Sentenced
Gabrielle Enright Weight Loss
2012 Street Glide Blue Book Value
拿到绿卡后一亩三分地
Craigslist Mount Pocono
Elgin Il Building Department
18 terrible things that happened on Friday the 13th
Fetus Munchers 1 & 2
VDJdb in 2019: database extension, new analysis infrastructure and a T-cell receptor motif compendium
Elven Steel Ore Sun Haven
The Nikki Catsouras death - HERE the incredible photos | Horror Galore
Chubbs Canton Il
Grand Park Baseball Tournaments
Makemkv Key April 2023
Where Is Darla-Jean Stanton Now
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 5802

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.