1.0.4 • Published 9 months ago

react-native-my-image-picker v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

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

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
1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago