zephyr.image

Render image assets inside the host for Discord attachments.

1 function

render_svg

image
zephyr.image.render_svg(svg, opts?)

Render SVG markup into PNG bytes.

svg is a Lua string containing SVG XML. Returns a Lua string containing raw PNG bytes, suitable for message.attachments[].data. opts.width scales the output width while preserving aspect ratio; opts.background accepts #RRGGBB, #RRGGBBAA, or transparent values.

Parameters

svgstring

SVG XML.

optstableoptional

Optional { width = number, background = string }.

Returns

string

Raw PNG bytes.

Raises an error if

  • the image permission is not granted

Example

lua
local png = zephyr.image.render_svg("<svg width='64' height='64'><rect width='64' height='64' fill='red'/></svg>")
zephyr.discord.respond({ attachments = { { filename = "card.png", data = png } } })