Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jimp/plugin-print

Package Overview
Dependencies
Maintainers
2
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jimp/plugin-print

print an image.

  • 0.3.8
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-3.77%
Maintainers
2
Weekly downloads
 
Created
Source

@jimp/plugin-print

Print text on an image.

Functions to load fonts and print text on an images.

Included Fonts

  • FONT_SANS_8_BLACK
  • FONT_SANS_10_BLACK
  • FONT_SANS_12_BLACK
  • FONT_SANS_14_BLACK
  • FONT_SANS_16_BLACK
  • FONT_SANS_32_BLACK
  • FONT_SANS_64_BLACK
  • FONT_SANS_128_BLACK
  • FONT_SANS_8_WHITE
  • FONT_SANS_16_WHITE
  • FONT_SANS_32_WHITE
  • FONT_SANS_64_WHITE
  • FONT_SANS_128_WHITE

loadFont

Loads a bitmap font from a file

  • @param {string} file the file path of a .fnt file
  • @param {function(Error, Jimp)} cb (optional) a function to call when the font is loaded
  • @returns {Promise} a promise
import jimp from 'jimp';

async function main() {
  const font = await jimp.read(jimp.FONT_SANS_32_BLACK);
}

main();

print

Draws a text on a image on a given boundary

_ @param {Jimp} font a bitmap font loaded from Jimp.loadFont command _ @param {number} x the x position to start drawing the text _ @param {number} y the y position to start drawing the text _ @param {string} text the text to draw (string or object with text, alignmentX, and/or alignmentY) _ @param {number} maxWidth (optional) the boundary width to draw in _ @param {number} maxHeight (optional) the boundary height to draw in * @param {function(Error, Jimp)} cb (optional) a function to call when the text is written

import jimp from 'jimp';

async function main() {
  const font = await jimp.read(jimp.FONT_SANS_32_BLACK);
  const image = await jimp.read(1000, 1000, 0x0000ffff);

  image.print(font, 10, 10, 'Hello World!');
}

main();

measureText

Measure how wide a piece of text will be.

import jimp from 'jimp';

async function main() {
  const font = await jimp.read(jimp.FONT_SANS_32_BLACK);
  const image = await jimp.read(1000, 1000, 0x0000ffff);

  image.measureText(font, 'Hello World!');
}

main();

measureTextHeight

Measure how tall a piece of text will be.

import jimp from 'jimp';

async function main() {
  const font = await jimp.read(jimp.FONT_SANS_32_BLACK);
  const image = await jimp.read(1000, 1000, 0x0000ffff);

  image.measureTextHeight(font, 'Hello World!', 100);
}

main();

FAQs

Package last updated on 27 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc