ImageReader

For photo album reading or photos taking

Import

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

// Image processing plugin, refer to #imageProcessor for usage,only support web

Vue.createApp().component(ImageReader.name, ImageReader)

Code Examples

API

ImageReader Props

PropsDescriptionTypeDefaultNote
nameidentifierString-used to distinguish multiple readers
maxSizeimage size limitString/Number-unit kb
acceptsupported image types,only support webArray*such as ['jpeg','png']
is-camera-onlyonly support photographingBooleanfalse-
is-multiplesupport selection of multiple sheets,only support webBooleanfalsethere is a compatibility issue
max-amountnumber of sheetsNumber-valid only when is-multiple is true
disabled-Booleanfalse-
is-processorimage quality compressionBooleanfalse-

ImageReader Events

@select(name, { files })

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

ParametersDescriptionTypeNote
nameidentifierString-
filesimage file objects setArray<File>-
@complete(name, { dataUrl, blob, file })

Picture reading completed

ParametersDescriptionTypeNote
nameidentifierString-
dataUrlbase64String-
blobimage Blob object for formData,only support webBlob-
fileimage file objectFile-
@error(name, { code, msg })

Picture selection and reading failed

ParametersDescriptionTypeNote
nameidentifierString-
codeerror identifierString-
msgerror messageString-

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

PropsDescriptionTypeNote
dataUrlbase64String-
widthpicture widthNumberunit px, scaled when width exceeds
heightpicture heightNumberunit px, scaled when height exceeds
qualitypicture qualityNumbervalue 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'