MCPcopy Create free account
hub / github.com/pollinations/pollinations / renderOg

Function renderOg

tools/icons/src/render.js:85–122  ·  view source on GitHub ↗
(
    lotusSvg,
    textSvg,
    {
        width = 1200,
        height = 630,
        bg,
        logoColor,
        lotusSize = 230,
        textWidth = 470,
        gap = 34,
    },
)

Source from the content-addressed store, hash-verified

83 * thumbnails apply.
84 */
85export async function renderOg(
86 lotusSvg,
87 textSvg,
88 {
89 width = 1200,
90 height = 630,
91 bg,
92 logoColor,
93 lotusSize = 230,
94 textWidth = 470,
95 gap = 34,
96 },
97) {
98 const lotus = await rasterize(lotusSvg, logoColor, lotusSize, lotusSize);
99 const text = await rasterize(textSvg, logoColor, textWidth, height);
100
101 const stackH = lotus.h + gap + text.h;
102 const top = Math.round((height - stackH) / 2);
103 const cx = width / 2;
104 return sharp({
105 create: {
106 width,
107 height,
108 channels: 4,
109 background: { ...hexToRgb(bg), alpha: 1 },
110 },
111 })
112 .composite([
113 { input: lotus.buf, left: Math.round(cx - lotus.w / 2), top },
114 {
115 input: text.buf,
116 left: Math.round(cx - text.w / 2),
117 top: top + lotus.h + gap,
118 },
119 ])
120 .png()
121 .toBuffer();
122}

Callers 2

render.test.jsFile · 0.90
generateFunction · 0.90

Calls 2

rasterizeFunction · 0.85
hexToRgbFunction · 0.70

Tested by

no test coverage detected