0.4.0 • Published 1 year ago

ezog v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

EZOG

EZOG is a JavaScript generator that can easily generate OG images without using a browser.

Features

  • Support for custom fonts.
  • Support for font size and line height.
  • Support for ellipsis.
  • Support for word breaking.
  • Support for specifying number of lines.
  • Support for Twemoji.
  • Support for embedding images.

Installation

npm install ezog

Example

import { generate, defaultFonts } from 'ezog';
import { fetch } from 'undici';

const png = await generate(
    [
        {
            type: 'image',
            buffer: baseImageBuffer, // Buffer / ArrayBuffer
            x: 0,
            y: 0,
            width: 1200,
            height: 630
        },
        {
            type: 'textBox',
            text: 'Hello, World',
            x: 0,
            y: 275,
            width: 1200,
            fontFamily: ['Sans', 'Noto Sans 700'],
            fontSize: 60,
            lineHeight: 80,
            lineClamp: 1, // optional
            align: 'center', // optional 'left' / 'right' / 'center'
            color: '#000' // optional
        }
    ],
    {
        width: 1200,
        height: 630,
        fonts: [
            {
                type: 'normalFont',
                name: 'Sans',
                data: fontSansBuffer // Buffer / ArrayBuffer
            },
            {
                type: 'googleFont',
                name: 'Noto Sans 700',
                googleFontName: 'Noto+Sans',
                weight: 700
            },
            ...defaultFonts(700 /* weight: optional */) // load multilingual Noto Sans from google fonts
        ],
        background: '#fff', // optional
        fetch: fetch // optional
    }
);
0.3.0

1 year ago

0.3.2

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.2.2

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago