# react-native-image-picker-name

> A React Native module that allows you to use native UI to select media from the device library or directly from the camera

Latest version **5.0.0** (published 2023-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-image-picker-name
pnpm add react-native-image-picker-name
yarn add react-native-image-picker-name
bun add react-native-image-picker-name
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-09-06 |
| First published | 2023-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 139.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | quoccuongccvn |
| Maintainers | quoccuongccvn |
| Keywords | react-native, react-native-image-picker-name, react, native, image, picker |

## Links

- npm: https://www.npmjs.com/package/react-native-image-picker-name
- Repository: https://github.com/react-native-image-picker-name/react-native-image-picker-name
- Issues: https://github.com/react-native-image-picker-name/react-native-image-picker-name/issues
- npm.io page: https://npm.io/package/react-native-image-picker-name

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2023-09-06
- 4.0.7 — 2023-09-06
- 4.0.6 — 2023-09-06

## README

# React Native Image Picker

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

<p align="center">
  <img src="https://img.shields.io/npm/dw/react-native-image-picker-name" />
  <img src="https://img.shields.io/npm/v/react-native-image-picker-name" />
</p>

### 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.


# Install

```
yarn add react-native-image-picker-name

# RN >= 0.60
cd ios && pod install

# RN < 0.60
react-native link react-native-image-picker-name
```

## 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-on-file-storage)).

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

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

### `launchCamera()`

Launch camera to take photo or video.

```js
launchCamera(options?, callback);
```

See [Options](#options) for further information on `options`.

The `callback` will be called with a response object, refer to [The Response Object](#the-response-object).

### `launchImageLibrary`

Launch gallery to pick image or video.

```js
launchImageLibrary(options?, callback)
```

See [Options](#options) for further information on `options`.

The `callback` will be called with a response object, refer to [The Response Object](#the-response-object).

## Options

| Option        | iOS | Android | Description                                                                                           |
| ------------- | --- | ------- | ----------------------------------------------------------------------------------------------------- |
| mediaType     | OK  | OK      | 'photo' or 'video' or 'mixed'(mixed supported only for launchImageLibrary, to pick an photo or video) |
| maxWidth      | OK  | OK      | To resize the image                                                                                   |
| maxHeight     | OK  | OK      | To resize the image                                                                                   |
| videoQuality  | OK  | OK      | 'low', 'medium', or 'high' on iOS, 'low' or 'high' on Android                                         |
| durationLimit | OK  | OK      | Video max duration in seconds                                                                         |
| quality       | OK  | OK      | 0 to 1, photos                                                                                        |
| cameraType    | OK  | OK      | 'back' or 'front'. May not be supported in few android devices                                        |
| includeBase64 | OK  | OK      | If true, creates base64 string of the image (Avoid using on large image files due to performance)     |
| saveToPhotos  | OK  | OK      | (Boolean) Only for launchCamera, saves the image/video file captured to public photo                  |
| selectionLimit| OK  | OK      | Default is `1`, use `0` to allow any number of files. Only iOS version >= 14 support `0` and also it supports providing any integer value|

## The Response Object

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

## Asset Object

| key      | iOS | Android | Description                                                                                                                                                                                                                                |
| -------- | --- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| base64   | OK  | OK      | The base64 string of the image (photos only)                                                                                                                                                                                               |
| uri      | OK  | OK      | 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 |
| width    | OK  | OK      | Image dimensions (photos only)                                                                                                                                                                                                             |
| height   | OK  | OK      | Image dimensions (photos only)                                                                                                                                                                                                             |
| fileSize | OK  | OK      | The file size (photos only)                                                                                                                                                                                                                |
| type     | OK  | OK      | The file type (photos only)                                                                                                                                                                                                                |
| fileName | OK  | OK      | The file name                                                                                                                                                                                                                              |
| duration | OK  | OK      | The selected video duration in seconds                                                                                                                                                                                                     |

## 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

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

## License

[MIT](LICENSE.md)

---
_Source: https://npm.io/package/react-native-image-picker-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
