MCPcopy
hub / github.com/jimp-dev/jimp / createTextImage

Function createTextImage

plugins/plugin-print/src/index.node.test.ts:13–43  ·  view source on GitHub ↗
(
  width: number,
  height: number,
  font: string,
  {
    x = 0,
    y = 0,
    text,
    maxWidth,
    maxHeight,
  }: {
    text:
      | string
      | {
          text: string;
          alignmentX?: HorizontalAlign;
          alignmentY?: VerticalAlign;
        };
    maxWidth?: number;
    maxHeight?: number;
    x?: number;
    y?: number;
  },
)

Source from the content-addressed store, hash-verified

11const Jimp = createJimp({ plugins: [methods], formats: [png, jpeg] });
12
13async function createTextImage(
14 width: number,
15 height: number,
16 font: string,
17 {
18 x = 0,
19 y = 0,
20 text,
21 maxWidth,
22 maxHeight,
23 }: {
24 text:
25 | string
26 | {
27 text: string;
28 alignmentX?: HorizontalAlign;
29 alignmentY?: VerticalAlign;
30 };
31 maxWidth?: number;
32 maxHeight?: number;
33 x?: number;
34 y?: number;
35 },
36) {
37 const loadedFont = await loadFont(font);
38 const image = new Jimp({ width, height, color: 0xffffffff });
39
40 return image
41 .print({ font: loadedFont, x, y, text, maxWidth, maxHeight })
42 .getBuffer("image/png");
43}
44
45describe("Write text over image", function () {
46 const fontDefs = {

Callers 1

index.node.test.tsFile · 0.85

Calls 2

loadFontFunction · 0.85
getBufferMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…