# @koimy/rn-image-picker

> 选择图片

Latest version **1.0.2** (published 2020-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @koimy/rn-image-picker
pnpm add @koimy/rn-image-picker
yarn add @koimy/rn-image-picker
bun add @koimy/rn-image-picker
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-08-12 |
| First published | 2020-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mashizhen |
| Maintainers | dohard |
| Keywords | koimy, cimforce, atom, 原子操作, ai |

## Links

- npm: https://www.npmjs.com/package/@koimy/rn-image-picker
- Repository: https://gitee.com/dfeidao/widgets-mobile
- npm.io page: https://npm.io/package/@koimy/rn-image-picker

## Dependencies (1)

- [react-native-image-crop-picker](https://npm.io/package/react-native-image-crop-picker.md) ^0.32.2

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-08-12
- 1.0.1 — 2020-08-12
- 1.0.0 — 2020-08-12

## README

# 选择图片

## 安装

```bash
yarn add @koimy/rn-image-picker
```

## 配置

android/build.gradle

```gradle
allprojects {
	repositories {

		...
		maven { url 'https://maven.google.com' }
		maven { url 'https://www.jitpack.io' }
	}
}
```

android/app/build.gradle

```gradle
android {
	...
	defaultConfig {
		...
		vectorDrawables.useSupportLibrary = true					// 选择图片
	}
}
```

android/app/src/main/AndroidManifest.xml

```xml
	<uses-permission android:name="android.permission.CAMERA" />

	<!-- 前置摄像头 -->
	<uses-feature android:name="android.hardware.camera" android:required="false" />
	<uses-feature android:name="android.hardware.camera.front" android:required="false" />
```

## 使用示例

```tsx

import React, { useState } from 'react';
import { Image, Text, TouchableOpacity } from 'react-native';
import image_picker, { ImageData } from '@koimy/rn-image-picker';

export default () => {

	// 图片
	const [image, set_image] = useState<ImageData>({});

	/**
	 * 选取图片
	 */
	const picker = async () => {
		const res = await image_picker({
			multiple: false,
			mediaType: 'photo'
		});
		set_image(res[0]);
	};


	return (
		<TouchableOpacity style={{ width: '100%', height: '100%' }} onPress={() => picker()}>
			{
				image.path ? (
					<Image resizeMode='cover' style={{ width: '100%', height: '100%' }} source={{ uri: image.path }}></Image>
				) : (
						<Text>选择图片</Text>
					)
			}
		</TouchableOpacity>
	);
};

```

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