Blueprint - describe image content
Describe and control the content in an image
Migration notice
The "blueprint" is the content protocol used only by the legacy API. It no longer receives new features.
We strongly recommend migrating to the Generate image from template API. Design your template in HTML and define variables in the template editor; once it's published, you only need to pass in variables to generate images:
- HTML-based templates: Use the familiar tag structure of front-end development instead of the complex "blueprint" JSON protocol.
- Modern styling: Full support for inline styles (
style) and Tailwind CSS classes for quick layout. - Variables and conditional rendering: Reduce the data you need to send with each request.
- Multiple export formats: Export high-quality images as WebP, PNG, or JPEG.
imgrender can describe image content with a specific JSON document. We call that document a blueprint. The blueprint determines how an image is rendered and what the image contains.
The properties and structure of a blueprint are described below.
Blueprint
A blueprint fully describes the image dimensions and the content in the image. The properties are:
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| width | int | yes | Image width. Content cannot exceed this width. Maximum 1100. | |
| height | int | yes | Image height. Content cannot exceed this height. Maximum 2480. | |
| backgroundColor | Hex Color Code | yes | Image background color. Must be a hexadecimal color code. | |
| borderColor | Hex Color Code | #000000 | Color of the four borders. | |
| borderWidth | int | 0 | Width of the four borders. Half of the border width lies inside and half lies outside. This split cannot be adjusted yet. | |
| borderRadius | int | 0 | Corner radius of the four border corners. | |
| borderTopLeftRadius | int | 0 | Corner radius of the top-left border corner. Takes priority over borderRadius. | |
| borderTopRightRadius | int | 0 | Corner radius of the top-right border corner. Takes priority over borderRadius. | |
| borderBottomLeftRadius | int | 0 | Corner radius of the bottom-left border corner. Takes priority over borderRadius. | |
| borderBottomRightRadius | int | 0 | Corner radius of the bottom-right border corner. Takes priority over borderRadius. | |
| texts | Array | [] | Text in the image. See Text. | |
| images | Array | [] | Images in the picture. An external image can be rendered onto the new image. See Image. | |
| lines | Array | [] | Lines in the image, useful as dividers. See Line. | |
| qrcodes | Array | [] | QR codes in the image. A QR code can be rendered on the image. See QR code. | |
| blocks | Array | [] | Rectangles in the image. See Rectangle. |
Example
{
"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": "You're invited to join the giveaway",
"font": "jiangxizhuokai",
"fontSize": 22,
"color": "#fff",
"width": 320,
"textAlign": "center",
"zIndex": 1
},
{
"x": 30,
"y": 640,
"text": "Prize: Honda CB650R motorcycle",
"font": "jiangxizhuokai",
"fontSize": 22,
"color": "#000",
"width": 580,
"textAlign": "left",
"zIndex": 1
},
{
"x": 30,
"y": 676,
"text": "Automatic drawing at 18:00 on January 31",
"font": "jiangxizhuokai",
"fontSize": 18,
"color": "#9a9a9a",
"width": 580,
"textAlign": "left",
"zIndex": 1
},
{
"x": 320,
"y": 960,
"text": "Press and hold the QR code to join the giveaway",
"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
}
]
}The components that describe image content are covered below.
Coordinate system
Before the individual components, you need the coordinate system. It controls where elements are placed on the image.
imgrender uses this coordinate system:
-
The top-left corner is the
global origin (0,0). -
The X axis runs from left to right, and the Y axis runs from top to bottom.
-
The unit is pixels (px).
Text
The text component adds text to an image.
The properties are:
Properties
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| x | int | yes | Text X coordinate. | |
| y | int | yes | Text Y coordinate. | |
| text | string | yes | Text content. | |
| width | int | yes | Text width. Sets the maximum display width. Text that exceeds this width wraps automatically. | |
| font | string | SourceHanSansSC-Normal | Font used to render the text. See Font. | |
| fontSize | int | 18 | Font size, in pt. | |
| lineHeight | int | Base font height | Line height. Cannot be smaller than fontSize. | |
| lineSpacing | float | 1 | Line-spacing multiplier. lineSpacing * fontSize = lineHeight. | |
| color | Array | #000000 | Text color. | |
| textAlign | string | left | Horizontal alignment. Allowed values: left, center, and right. | |
| zIndex | int | 0 | Stacking order. Affects how content in the same position covers other content. |
Anchor
The textAlign property affects the text anchor.
As shown in the figure above, the dashed box is the display width and line height of the text.
For the text Prize: Honda CB650R, textAlign is left, so the anchor is at the top-left corner of the text.
For the text Press and hold the QR code to join the giveaway, textAlign is center, so the anchor is at the top center of the text.
For the text Davinci Li, textAlign is right, so the anchor is at the top-right corner of the text.
Font
Custom fonts are not supported yet. imgrender currently provides the following fonts, which are free for commercial use:
To add more fonts that are free for commercial use, contact the developer.

| Font name | Name |
|---|---|
| jiangxizhuokai | Jiangxi Zhuokai |
| slideyouran | Slide Youran Xiaokai |
| SourceHanSansSC-Heavy | Source Han Sans SC Heavy |
| SourceHanSansSC-Bold | Source Han Sans SC Bold |
| SourceHanSansSC-Medium | Source Han Sans SC Medium |
| SourceHanSansSC-Regular | Source Han Sans SC Regular |
| SourceHanSansSC-Normal | Source Han Sans SC Normal |
| SourceHanSansSC-Light | Source Han Sans SC Light |
| SourceHanSansSC-ExtraLight | Source Han Sans SC ExtraLight |
| SourceHanSerifCN-Heavy | Source Han Serif CN Heavy |
| SourceHanSerifCN-Bold | Source Han Serif CN Bold |
| SourceHanSerifCN-SemiBold | Source Han Serif CN SemiBold |
| SourceHanSerifCN-Medium | Source Han Serif CN Medium |
| SourceHanSerifCN-Regular | Source Han Serif CN Regular |
| SourceHanSerifCN-Light | Source Han Serif CN Light |
| SourceHanSerifCN-ExtraLight | Source Han Serif CN ExtraLight |
| Alibaba-PuHuiTi-Heavy | Alibaba PuHuiTi Heavy |
| Alibaba-PuHuiTi-Bold | Alibaba PuHuiTi Bold |
| Alibaba-PuHuiTi-Medium | Alibaba PuHuiTi Medium |
| Alibaba-PuHuiTi-Regular | Alibaba PuHuiTi Regular |
| Alibaba-PuHuiTi-Light | Alibaba PuHuiTi Light |
Example
{
"x": 320,
"y": 185,
"text": "Davinci Li",
"font": "SourceHanSansSC-Normal",
"fontSize": 22,
"color": "#fff",
"width": 320,
"textAlign": "center"
}Image
The image component adds an image to the picture, for example a custom background.
The image URL must be accessible so the file can be downloaded.
Supported image formats: gif, jpeg, png, bmp, tiff, and webp.
Properties
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| x | int | yes | Image X coordinate. | |
| y | int | yes | Image Y coordinate. | |
| url | url | yes | Image URL. The image must be accessible for download. Supported formats: gif, jpeg, png, bmp, tiff, and webp. | |
| width | int | yes | Rendered width, used to scale the image. | |
| height | int | yes | Rendered height, used to scale the image. | |
| borderColor | Hex Color Code | #000000 | Color of the four borders. | |
| borderWidth | int | 0 | Width of the four borders. | |
| strokeAlign | string | CENTER | Border alignment. Allowed values: CENTER (center), INSIDE (inside), and OUTSIDE (outside). | |
| borderRadius | int | 0 | Corner radius of the four border corners. | |
| borderTopLeftRadius | int | 0 | Corner radius of the top-left border corner. Takes priority over borderRadius. | |
| borderTopRightRadius | int | 0 | Corner radius of the top-right border corner. Takes priority over borderRadius. | |
| borderBottomLeftRadius | int | 0 | Corner radius of the bottom-left border corner. Takes priority over borderRadius. | |
| borderBottomRightRadius | int | 0 | Corner radius of the bottom-right border corner. Takes priority over borderRadius. | |
| zIndex | int | 0 | Stacking order. Affects how content in the same position covers other content. |
Example
{
"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
}Line
The line component adds a line to an image. Use it to draw dividers, underlines, and similar marks.
Properties
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| startX | int | yes | Start X coordinate. | |
| startY | int | yes | Start Y coordinate. | |
| endX | int | yes | End X coordinate. | |
| endY | int | yes | End Y coordinate. | |
| width | int | yes | Line width. | |
| color | Hex Color Code | #000000 | Line color. | |
| zIndex | int | 0 | Stacking order. |
Example
{
"startX": 30,
"startY": 696,
"endX": 610,
"endY": 696,
"width": 1,
"color": "#E1E1E1",
"zIndex": 1
}Rectangle
The rectangle component adds a rectangle to an image.
Properties
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| x | int | yes | Rectangle X coordinate. | |
| y | int | yes | Rectangle Y coordinate. | |
| width | int | yes | Rectangle width. | |
| height | int | yes | Rectangle height. | |
| backgroundColor | Hex Color Code | #000000 | Background color. | |
| borderColor | Hex Color Code | #000000 | Color of the four borders. | |
| borderWidth | int | 0 | Width of the four borders. | |
| strokeAlign | string | CENTER | Border alignment. Allowed values: CENTER (center), INSIDE (inside), and OUTSIDE (outside). | |
| borderRadius | int | 0 | Corner radius of the four border corners. | |
| borderTopLeftRadius | int | 0 | Corner radius of the top-left border corner. Takes priority over borderRadius. | |
| borderTopRightRadius | int | 0 | Corner radius of the top-right border corner. Takes priority over borderRadius. | |
| borderBottomLeftRadius | int | 0 | Corner radius of the bottom-left border corner. Takes priority over borderRadius. | |
| borderBottomRightRadius | int | 0 | Corner radius of the bottom-right border corner. Takes priority over borderRadius. | |
| zIndex | int | 0 | Stacking order. Affects how content in the same position covers other content. |
Example
{
"x": 220,
"y": 100,
"width": 380,
"height": 200,
"backgroundColor": "#fff",
"borderColor": "#fff"
}QR code
The QR code component adds a QR code to an image, for example a QR code for a share link.
Parameters
| Field name | Data type | Default | Required | Description |
|---|---|---|---|---|
| x | int | yes | QR code X coordinate. | |
| y | int | yes | QR code Y coordinate. | |
| size | int | yes | Size of the square QR code. | |
| content | string | yes | QR code content. | |
| foregroundColor | Hex Color Code | #000000 | QR code foreground color. | |
| backgroundColor | Hex Color Code | #ffffff | QR code background color. | |
| zIndex | int | 0 | Stacking order. Affects how content in the same position covers other content. |
The QR code component has a border in the background color, such as the white border around the QR code in the figure above. Border thickness is determined by both the QR code size and the length of the encoded content. For example, when size is 200px but the encoded content is only the character a, the border is wider than in the figure above. Set the QR code background color to the same color as the surrounding area to remove the effect of that border.
Example
{
"x": 208,
"y": 726,
"size": 200,
"content": "http://weixin.qq.com/r/yRzk-JbEbMsTrdKf90nb",
"foregroundColor": "#000",
"backgroundColor": "#fff",
"zIndex": 1
}