Skip to content

Commit 8836014

Browse files
matihabbasst0ffern
authored andcommitted
feat(filePath): Support filePath prop to save to file
Closes #39
1 parent f853f87 commit 8836014

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ yarn add react-native-image-cropper
2929
- `pinchToZoom` Use pinch to zoom image? (default: true)
3030
- `quality`: a value from 0 to 1 to describe the quality of the snapshot. 0 means 0% (most compressed) and 1 means 100% (best quality). (default: 1)
3131
- `type`: the file type default value is **"png"**, **"jpg"** is also supported. Refer to implementations to see more supported values. (default: jpg)
32+
- `format`: the format of the output. Supported values: **"base64"**, **"file"**. (default: base64)
33+
- `filePath`: if format is **"file"**, the path to write the image to (default: "")
3234
- `pixelRatio`: the pixel ratio to use for the rendering. By default the screen pixel scale will be used.
3335

3436
#### `{ImageCrop}` Functions

src/ImageCrop.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class ImageCrop extends Component {
191191
)
192192
}
193193
crop(){
194-
return this.refs.cropit.captureFrame({quality: this.props.quality, type: this.props.type, format: this.props.format})
194+
return this.refs.cropit.captureFrame({quality: this.props.quality, type: this.props.type, format: this.props.format, filePath: this.props.filePath})
195195
}
196196
}
197197
ImageCrop.defaultProps = {
@@ -205,6 +205,7 @@ ImageCrop.defaultProps = {
205205
pixelRatio: PixelRatio.get(),
206206
type: 'jpg',
207207
format: 'base64',
208+
filePath: ''
208209
}
209210
ImageCrop.propTypes = {
210211
image: React.PropTypes.string.isRequired,
@@ -217,5 +218,6 @@ ImageCrop.propTypes = {
217218
pixelRatio: React.PropTypes.number,
218219
type: React.PropTypes.string,
219220
format: React.PropTypes.string,
221+
filePath: React.PropTypes.string
220222
}
221223
module.exports=ImageCrop

0 commit comments

Comments
 (0)