APIs¶
Overview¶
Image Processing includes 3 steps, which are uploading, processing and downloading (or showing).
Uploading¶
upload image to Tencent COS.
Authorization¶
Send a GET query for getting a temp secret key to your authorization server.
| Parameter | Type | Value |
| method | str | “POST”,which is the upload method. |
| pathname | str | “/”, which is the path in COS. |
| key | str | File name |
File uploading¶
Using Tencent COS JavaScript SDK to send a POST query for uploading file to Tencent COS server directly. The file size is limited to 20M.
| Parameter | Value |
| Authoriza | Signature generated by previous request. |
| x-cos-security-token | The sessionToken of the temp secret key. |
Processing¶
Fetching¶
Send a POST query with a json for processing uploaded file.
- ‘Content-Type’: ‘application/json’
Field Description
| Parameter | Type | Value |
| file_name | str | File name |
| op | int | Operation number (0 - 7) |
| op_par | dict | Operation parameter |
QR code¶
Field Description
| Parameter | Type | Value |
| content | str | String store in QR code. |
| position | int or dict | When fixed = 0, the position of QR Code has 5 choices: 1 for Upper Left, 2 for Upper Right, 3 for Center, 4 for Bottom Left, 5 for Bottom Right (default = 5). When fixed = 1, the position is defined by the pixel point in the original graph (width, height). |
| fixed | int | 0 for using relative position, 1 for using fixed pixel position. (default = 0) |
Round¶
Field Description
| Parameter | Type | Value |
| radius | float | If fixed = 0, radius represent in ratio; If fixed = 1, radius represent in pixel. |
| fixed | int | 0 for using relative position, 1 for using fixed pixel position. (default = 0) |
Thumbnail¶
Field Description
| Parameter | Type | Value |
| height | int | Thumbnail height |
| width | int | Thumbnail width |
Watermark with text¶
Field Description
| Parameter | Type | Value |
| content | str | The water mark text |
| font_name | str | The name of font style |
| size_ratio | float | The size of water mark based on input figure |
| rotate_angle | int | The rotate angle for text. Counter clock |
| clear_ratio | float | The contrast between the watermark and the background |
| position | int or dict | When fixed = 0, the position of QR Code has 5 choices: 1 for Upper Left, 2 for Upper Right, 3 for Center, 4 for Bottom Left, 5 for Bottom Right (default = 5). When fixed = 1, the position is defined by the pixel point in the original graph (width, height). |
| fixed | int | 0 for using relative position, 1 for using fixed pixel position. (default = 0) |
Watermark with image¶
Field Description
| Parameter | Type | Value |
| patch | str | The path for water mark image |
| clear_ratio | float | The contrast between the watermark and the background |
| position | int or dict | When fixed = 0, the position of QR Code has 5 choices: 1 for Upper Left, 2 for Upper Right, 3 for Center, 4 for Bottom Left, 5 for Bottom Right (default = 5). When fixed = 1, the position is defined by the pixel point in the original graph (width, height). |
| fixed | int | 0 for using relative position, 1 for using fixed pixel position. (default = 0) |
Slicing¶
Field Description
| Parameter | Type | Value |
| num | int | number of slices |
| direction | int | 1 for slice vertical, 0 for slice horizontal |
Processing Response¶
Previous query response a json.
Field Description
| Parameter | Type | Value |
| data | dict | All processed files’ name |
| file_cnt | int | File count in the data field |
Downloading¶
Previous query will return a download file name. Then, the processed image can be downloaded from Tencent COS.