# cropImage

裁剪图片 

## API 调用

### QN.app.invoke({api:'cropImage', query})

#### API 调用入参

参数名             | 类型       | 是否可选 | 默认值 | 含义
:-------------- | :------- | :--- | :-- | :-----------------------------------------------------------------------------------------------------------------------
`query`         | `Object` |      |     |
`query.type`  | `string` |  可选    |  dataurl | 数据类型：dataurl(base64), fileurl(本地路径), remoteurl(服务器路径）
`query.data`  | `string` |  可选    |  http://aa.com/xxxx.png | 当type为dataurl时，该字段为经过base64的图片数据 当type为fileurl时，该字段为图片的全路径 当type为remoteurl时，该字段为图片的网络URL
`query.clipWidth`  | `number` |  可选    |  200 | 最大宽度
`query.clipHeight`  | `number` |  可选    |  100 | 最大高度
`query.initWidth`  | `number` |  可选    |  500 | 裁剪框初始化宽度，单位：像素
`query.initHeight`  | `number` |  可选    |  500 | 裁剪框初始化高度，单位：像素
`query.fixedRatio`  | `enum` |  可选    |  fixedRatio | 固定拉伸比例,可选值: fixedRatio：必须传initWidth和initHeight，按照初始化宽高拉伸; fixedSize： 必须传initWidth和initHeight（固定大小，不能拉伸）


#### API 响应结果

参数名      | 类型  | 示例 | 含义
:------- | :-- | :----- | :---
`result` | `*` |        | 请求响应
`query.res`  | `string` |  <need>    |  <default> | 图片二进制进行base64之后的字符串


#### 调用示例

```javascript
QN.app.invoke({
      api:'cropImage',
      query:{
                type : 'dataurl'  ,
                    data : 'http://aa.com/xxxx.png'  ,
                    clipWidth : 200  ,
                    clipHeight : 100  ,
                    initWidth : 500  ,
                    initHeight : 500  ,
                    fixedRatio : 'fixedRatio'  
            
      }
}).then(result => {
    console.log(result);
}, error => {
    console.log(error);
});
    
```
