-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangcuijuan
committed
Dec 19, 2024
1 parent
7b34d47
commit 0a0a399
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js' | ||
import { Image } from 'react-native' | ||
|
||
const previewImage = envError('previewImage') | ||
|
||
const compressImage = envError('compressImage') | ||
|
||
const getImageInfo = function (options = {}) { | ||
const { src, success, fail, complete } = options | ||
if (src === undefined) { | ||
const result = { | ||
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;', | ||
errno: 1001 | ||
} | ||
failHandle(result, fail, complete) | ||
return | ||
} | ||
if (src === '') { | ||
return | ||
} | ||
Image.getSize(src, (width, height) => { | ||
const result = { | ||
errMsg: 'getImageInfo:ok', | ||
width, | ||
height | ||
} | ||
defineUnsupportedProps(result, ['path', 'orientation', 'type']) | ||
successHandle(result, success, complete) | ||
}, (err) => { | ||
const result = { | ||
errMsg: 'getImageInfo:fail download image fail. reason: ' + err | ||
} | ||
failHandle(result, fail, complete) | ||
}) | ||
} | ||
|
||
export { | ||
previewImage, | ||
compressImage, | ||
getImageInfo | ||
} |