功能描述 (此接口已废弃,不再提供维护,推荐使用接口LightSDK.native.imagePicker)
通过js接口页面中返回指定图片的base64编码字符串
支持格式
Json
请求参数:
字段 | 可选 | 类型及范围 | 说明 |
---|---|---|---|
imagePickType | 是 | string | 默认不传此参数的话,弹出选择使用用摄像头和单选相册的对话框进行选择。参数有4种type可选:camera,album,CAMERA_MUTIL-ALBUM,MUTIL-ALBUM。 1.camera 表示选用摄像头,会直接跳转拍照页面。 2.album 表示调用单选相册,会直接跳转相册页面 3.CAMERA_MUTIL-ALBUM 表示多选相册和相机,会有alert框提示选择”从手机相册选取”和”拍照”。 4.MUTIL-ALBUM 表示多选相册,会直接跳转相册页面。 |
cropPhoto | 是 | bool | 是否剪裁,默认情况下为true |
maxWidth | 是 | string | 最大宽度,表示自定义裁剪框的最大宽度 |
aspectXY | 是 | string | 宽高比,如9:16 默认情况下为1:1 注意:自定义裁剪框大小功能需要aspectXY和maxWidth两个都有值的情况才起效。 |
maxCount | 是 | string | 多选图片(即type为CAMERA_MUTIL-ALBUM或MUTIL-ALBUM)情况下可选的最大照片数,默认为9。 |
allowTakePicture | 是 | bool | 多选图片(即type为CAMERA_MUTIL-ALBUM或MUTIL-ALBUM)情况下相册选择器中是否显示拍照按钮,默认不显示,仅支持iOS |
reverselyOrdered | 是 | bool | 多选图片(即type为CAMERA_MUTIL-ALBUM或MUTIL-ALBUM)情况下相册选择器是否倒序显示,默认正序显示,仅支持iOS |
请求调用示例params={
"imagePickType":"camera",
"cropPhoto":true,
"maxWidth":"300",
"aspectXY":"9:16"
}
LightSDK.native.chooseImage(params,cb);
返回值说明
字段名 | 字段类型 | 说明 |
---|---|---|
result | string | 被选中图片的base64编码 |
imageBase64 | array | 被选中图片的base64编码数组 |
imageSize | array | 被选择图片的大小,单选则只有1个元素,多选则元素个数与imageBase64相同,元素类型number,单位byte |
返回字段示例
单选图片:"data": {"result":"iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAF0UlEQVR4nO3dQ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QohN7Zg5bePLXRtxhra2rH3N/p4D2TEDRxMhxEQIMRFCTIQQEyHERAgxEULs38W/PXnA/TXrG558kKGtGadd2+3PctoExdybrrkTQkyEEBMhxEQIMRFCTIQQEyHERAgxEUJsNTHzTUsN1nMSp82grP2S42sO3ACy4EAYuJgIISZCiIkQYiKEmAghJkKIiRBiIoTYamJm7bQpk6FJiAPHhrav/F3zNMnLJl+3OyHERAgxEUJMhBATIcRECDERQkyEENt/WL924BKBW97xiaGVEAceojL0psnX7U4IMRFCTIQQEyHERAgxEUJMhBATIcRECLGpiZm7vL/Z4ZuGRYau3vZfm8zEPHlTd0KIiRBiIoSYCCEmQoiJEGIihJgIISZCiJmY+fl5MH5x4MKSbYvP8uSDDI22bI/pnHbuzY87IeRECDERQkyEEBMhxEQIMRFCTIQQm3pYf9dz6oUnj4yTHRYLyZfy/kU4cIHFmjshxEQIMRFCTIQQEyHERAgxEUJMhBATIcT2J2ZOGwdJDK1gGHrZbQfuoTjtQJgn3AkhJkKIiRBiIoSYCCEmQoiJEGIihJgIIfY5cIAAfhV3QoiJEGIihJgIISZCiIkQYiKEmAghJkKI/QfOdxtqmV9A+gAAAABJRU5ErkJggg=="],"imageSize":[20004]}
注意事项
需要在config.js配置文件中做以下配置:
module.exports = { |
效果