React Native 图片选择器组件for Android , 基于react-native-image-crop-picker

react-native-my-image-picker

React Native image-picker component for Android , base on react-native-image-crop-picker. Supports photo or local album uploading.

React Native 图片选择器组件for Android,基于react-native-image-crop-picker开发,支持拍照或本地相册上传

小图标的显示用到了react-native-vector-icons

react-native-image-crop-picker的安装需要配置一下,详细请看github

https://github.com/ivpusic/react-native-image-crop-picker

github源码地址 https://github.com/ano-2/my-image-picker

Example

打开相机
在这里插入图片描述

打开相册

example

在这里插入图片描述

Install

$ npm install react-native-my-image-picker --save

Mostly automatic installation

If you are using React Native <= 0.59.X, link the native project:

$ react-native link react-native-my-image-picker

Usage

基础用法

# Basic usage
import MyImagePicker from 'react-native-my-image-picker'

<View style={{height:150,width:150}}>
	<MyImagePicker describe={'拍摄/上传'} callBackImage={(image)=>console.log(image)}/>
</View>

在这里插入图片描述

修改样式 containerStyle pickTextStyle

# Change style of container and text
import MyImagePicker from 'react-native-my-image-picker'

<View style={{height:150,width:150}}>
	<MyImagePicker containerStyle={{backgroundColor:'#eee',borderStyle: 'solid',borderWidth:1}} pickTextStyle={{color:'grey',fontSize:14}} describe={'拍摄/上传'} callBackImage={(image)=>console.log(image)}/>
</View>

在这里插入图片描述

自定义裁剪大小 crop={{width:500,height:500}}

# Modify crop range
import MyImagePicker from 'react-native-my-image-picker'

<View style={{height:150,width:150}}>
	<MyImagePicker crop={{width:500,height:500}} describe={'拍摄/上传国徽面'} callBackImage={(image)=>console.log(image)}/>
</View>

在这里插入图片描述

Properties

PropDefaultTypeDescription
describe无 (非必须)String
containerStyle无 (非必须)Object容器样式,可以设置边框样式颜色等
pickTextStyle无 (非必须)Object设置describe文字样式
cropwidth: 460, height: 287.5Object剪裁尺寸

methods

MethodParamsDescription
callBackImage-返回处理后的图片信息

Response Object (摘自react-native-image-crop-picker文档)

即 callBackImage={(image)=>console.log(image)} 中的image

根据自己的业务需求对取到的image进行处理,剪裁后的图片url在image.path

详细请看github

https://github.com/ivpusic/react-native-image-crop-picker

PropertyTypeDescription
pathstringSelected image location. This is null when the writeTempFile option is set to false.
localIdentifier(ios only)stringSelected images’ localidentifier, used for PHAsset searching
sourceURL(ios only)stringSelected images’ source path, do not have write access
filename(ios only)stringSelected images’ filename
widthnumberSelected image width
heightnumberSelected image height
mimestringSelected image MIME type (image/jpeg, image/png)
sizenumberSelected image size in bytes
durationnumberVideo duration time in milliseconds
database64Optional base64 selected file representation
exifobjectExtracted exif data from image. Response format is platform specific
cropRectobjectCropped image rectangle (width, height, x, y)
creationDate (ios only)stringUNIX timestamp when image was created
modificationDatestringUNIX timestamp when image was last modified
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值