imgrender 开放 API
  1. 图片生成
imgrender 开放 API
  • 接入必读
  • 状态码与错误码
  • 图片生成
    • 同步生成图片-v1
      POST
  1. 图片生成

同步生成图片-v1

POST
/v1/pics
根据传入的完整配置生成图片,返回图片的访问链接。
更多信息请查看 文档-生成图片

错误码#

错误码HTTP 状态码说明排查建议
20105403图片生成失败请根据提示信息处理

请求参数

Header 参数

Body 参数application/json

示例
{
    "width": 640,
    "height": 1050,
    "backgroundColor": "#d75650",
    "blocks": [
        {
            "x": 15,
            "y": 268,
            "width": 610,
            "height": 770,
            "backgroundColor": "#fff",
            "borderColor": "#fff"
        }
    ],
    "texts": [
        {
            "x": 320,
            "y": 185,
            "text": "Davinci Li",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#fff",
            "width": 320,
            "textAlign": "center",
            "zIndex": 1
        },
        {
            "x": 320,
            "y": 220,
            "text": "邀请你来参加抽奖",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#fff",
            "width": 320,
            "textAlign": "center",
            "zIndex": 1
        },
        {
            "x": 30,
            "y": 640,
            "text": "奖品: 本田-CB650R 摩托车",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#000",
            "width": 580,
            "textAlign": "left",
            "zIndex": 1
        },
        {
            "x": 30,
            "y": 676,
            "text": "01 月 31 日 18:00 自动开奖",
            "font": "jiangxizhuokai",
            "fontSize": 18,
            "color": "#9a9a9a",
            "width": 580,
            "textAlign": "left",
            "zIndex": 1
        },
        {
            "x": 320,
            "y": 960,
            "text": "长按识别二维码,参与抽奖",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#9a9a9a",
            "width": 580,
            "textAlign": "center",
            "zIndex": 1
        }
    ],
    "lines": [
        {
            "startX": 30,
            "startY": 720,
            "endX": 610,
            "endY": 720,
            "width": 1,
            "color": "#E1E1E1",
            "zIndex": 1
        }
    ],
    "images": [
        {
            "x": 248,
            "y": 25,
            "width": 120,
            "height": 120,
            "url": "https://img-chengxiaoli-1253325493.cos.ap-beijing.myqcloud.com/bikers_327390-13.jpg",
            "borderRadius": 60,
            "zIndex": 1
        },
        {
            "x": 108,
            "y": 285,
            "width": 400,
            "height": 300,
            "url": "https://img-chengxiaoli-1253325493.cos.ap-beijing.myqcloud.com/cb650R.jpeg",
            "zIndex": 1
        }
    ],
    "qrcodes": [
        {
            "x": 208,
            "y": 726,
            "size": 200,
            "content": "http://weixin.qq.com/r/yRzk-JbEbMsTrdKf90nb",
            "foregroundColor": "#000",
            "backgroundColor": "#fff",
            "zIndex": 1
        }
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.imgrender.net/open/v1/pics' \
--header 'X-API-Key: 请替换为你的应用密钥' \
--header 'Content-Type: application/json' \
--data-raw '{
    "width": 640,
    "height": 1050,
    "backgroundColor": "#d75650",
    "blocks": [
        {
            "x": 15,
            "y": 268,
            "width": 610,
            "height": 770,
            "backgroundColor": "#fff",
            "borderColor": "#fff"
        }
    ],
    "texts": [
        {
            "x": 320,
            "y": 185,
            "text": "Davinci Li",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#fff",
            "width": 320,
            "textAlign": "center",
            "zIndex": 1
        },
        {
            "x": 320,
            "y": 220,
            "text": "邀请你来参加抽奖",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#fff",
            "width": 320,
            "textAlign": "center",
            "zIndex": 1
        },
        {
            "x": 30,
            "y": 640,
            "text": "奖品: 本田-CB650R 摩托车",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#000",
            "width": 580,
            "textAlign": "left",
            "zIndex": 1
        },
        {
            "x": 30,
            "y": 676,
            "text": "01 月 31 日 18:00 自动开奖",
            "font": "jiangxizhuokai",
            "fontSize": 18,
            "color": "#9a9a9a",
            "width": 580,
            "textAlign": "left",
            "zIndex": 1
        },
        {
            "x": 320,
            "y": 960,
            "text": "长按识别二维码,参与抽奖",
            "font": "jiangxizhuokai",
            "fontSize": 22,
            "color": "#9a9a9a",
            "width": 580,
            "textAlign": "center",
            "zIndex": 1
        }
    ],
    "lines": [
        {
            "startX": 30,
            "startY": 720,
            "endX": 610,
            "endY": 720,
            "width": 1,
            "color": "#E1E1E1",
            "zIndex": 1
        }
    ],
    "images": [
        {
            "x": 248,
            "y": 25,
            "width": 120,
            "height": 120,
            "url": "https://img-chengxiaoli-1253325493.cos.ap-beijing.myqcloud.com/bikers_327390-13.jpg",
            "borderRadius": 60,
            "zIndex": 1
        },
        {
            "x": 108,
            "y": 285,
            "width": 400,
            "height": 300,
            "url": "https://img-chengxiaoli-1253325493.cos.ap-beijing.myqcloud.com/cb650R.jpeg",
            "zIndex": 1
        }
    ],
    "qrcodes": [
        {
            "x": 208,
            "y": 726,
            "size": 200,
            "content": "http://weixin.qq.com/r/yRzk-JbEbMsTrdKf90nb",
            "foregroundColor": "#000",
            "backgroundColor": "#fff",
            "zIndex": 1
        }
    ]
}'

返回响应

🟢200成功
application/json
Body

示例
{
    "code": 0,
    "message": "ok",
    "data": {
        "url": "https://davinci.imgrender.cn/6e31cfcd683a36d0522a8cc34e244379.jpg?sign=xxx"
    }
}
修改于 2023-08-15 10:07:08
上一页
状态码与错误码
Built with