mand-mobile/components/image-reader
zouhang 0020558282 fix: fix some bugs 2021-05-14 10:23:41 +08:00
..
demo example(image-reader): update style 2019-01-30 15:35:43 +08:00
test test: update cases 2019-01-22 17:45:20 +08:00
README.en-US.md doc: update preview links 2019-01-29 16:31:24 +08:00
README.md doc: update preview links 2019-01-29 16:31:24 +08:00
component.js Initial commit 2018-03-26 16:04:04 +08:00
image-dataurl.js test: add ignore comments 2019-01-22 17:46:53 +08:00
image-processor.d.ts fix(types): update type declaration 2018-08-01 00:52:11 +08:00
image-processor.js fix: fix some bugs 2021-05-14 10:23:41 +08:00
image-reader.js feature(image-reader):expose image file object #107 (#108) 2018-06-08 13:40:47 +08:00
index.vue test: add ignore comments 2019-01-22 17:46:53 +08:00

README.en-US.md

title preview
ImageReader https://didi.github.io/mand-mobile/examples/#/image-reader

For photo album reading or photos taking

Import

import { ImageReader } from 'mand-mobile'
import imageProcessor from 'mand-mobile/lib/image-reader/image-processor'

// Image processing plugin, refer to #imageProcessor for usage

Vue.component(ImageReader.name, ImageReader)

Code Examples

API

ImageReader Props

Props Description Type Default Note
name identifier String - used to distinguish multiple readers
size image size limit String/Number - unit kb
mime supported image types Array * such as ['jpeg','png']
is-camera-only only support photographing Boolean false -
is-multiple support selection of multiple sheets Boolean false there is a compatibility issue
amount number of sheets Number - valid only when is-multiple is true

ImageReader Events

@select(name, { files })

Picture selection completed, while reading hasn't been started yet

Parameters Description Type Note
name identifier String -
files image file objects set Array -
@complete(name, { dataUrl, blob, file })

Picture reading completed

Parameters Description Type Note
name identifier String -
dataUrl base64 String -
blob image Blob object for formData Blob -
file image file object File -
@error(name, { code, msg })

Picture selection and reading failed

Parameters Description Type Note
name identifier String -
code error identifier String -
msg error message String -

imageProcessor

For image axial correction, picture quality compression and height control

Import

import imageProcessor from 'mand-mobile/lib/image-reader/image-processor'

/**
 * options Image processing configuration
 * fn(dataUrl, blob) Process completes callback
 * @return Promise({dataUrl, blob})
 */
imageProcessor(options[, fn])

options

Props Description Type Note
dataUrl base64 String -
width picture width Number unit px, scaled when width exceeds
height picture height Number unit px, scaled when height exceeds
quality picture quality Number value range 0-1

Appendix

Picture read failed error code and error message

'100': 'browser does not support'
'101': 'picture size is beyond the preset'
'102': 'picture read failure'
'103': 'the number of pictures exceeds the limit'