ComfyDeploy: How ComfyUI_MarkdownImage works in ComfyUI?
What is ComfyUI_MarkdownImage?
This project generates an image from Markdown text using imgkit and wkhtmltoimage. It automatically scales the text to fit within the specified image dimensions.
How to install it in ComfyDeploy?
Head over to the machine page
- Click on the "Create a new machine" button
- Select the
Edit
build steps - Add a new step -> Custom Node
- Search for
ComfyUI_MarkdownImage
and select it - Close the build step dialig and then click on the "Save" button to rebuild the machine
CreateMarkdownImage ComfyUI node
This project generates an image from Markdown text using imgkit
and wkhtmltoimage
. It automatically scales the text to fit within the specified image dimensions.
🔧 Installation
1️⃣ Install Dependencies
pip install -r requirements.txt
2️⃣ Install wkhtmltoimage
This project requires wkhtmltoimage
, which is part of wkhtmltopdf
. You need to install it manually.
🔗 Download wkhtmltopdf
from:
👉 https://wkhtmltopdf.org/downloads.html
Make sure to add wkhtmltoimage.exe
to your system PATH, or update the script with its full path.
📌 How It Works
This script:
- Converts Markdown text into HTML.
- Renders the HTML into an image using
imgkit
. - Dynamically adjusts the font size to maximize readability.
- Returns the image as a PyTorch tensor.
📊 Input Fields
| Field | Type | Description |
|------------------|--------|-------------|
| md_text
| String | Markdown text to be rendered into an image. Supports basic formatting (bold, italic, emojis). |
| border_color
| String | HEX color or HTML named color for the image border (e.g., #FFFF00
for yellow). |
| border_size
| Int | Border thickness in pixels. |
| image_width
| Int | Width of the generated image in pixels. |
| image_height
| Int | Height of the generated image in pixels. |
| background_color
| String | HEX color or html color name (e.g., "lightblue"
). |
🚀 Usage
from create_markdown_image import CreateMarkdownImage
generator = CreateMarkdownImage()
image_tensor = generator.createmarkdownimage(
md_text="**Hello World!** 🚀",
border_color="#000000",
border_size=2,
image_width=800,
image_height=200,
background_color="white"
)
This will generate an image containing "Hello World! 🚀" with a black border and a white background.
🛠️ Troubleshooting
- If
imgkit
fails, ensurewkhtmltoimage.exe
is installed and accessible. - If text doesn't scale correctly, adjust the
image_width
andimage_height
fields.
📜 License
This project is licensed under the MIT License.