How to use the jimp.FONT_SANS_16_WHITE function in jimp

To help you get started, we’ve selected a few jimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pmlrsg / GISportal / app / scripts / animation-timestamper.js View on Github external
var async = require('async');
var Jimp = require('jimp');

// Create queue
var queue = async.queue(processImage, 2);

// Preload fonts
var fontB = null;
var fontW = null;
Jimp.loadFont(Jimp.FONT_SANS_16_BLACK).then(function(font) {
   fontB = font;
});
Jimp.loadFont(Jimp.FONT_SANS_16_WHITE).then(function(font) {
   fontW = font;
});

process.on('message', function(options) {
   // Add each image received to the queue
   queue.push(options, imageDone);
});

/**
 * Process an image to stamp it's ID (time) in the corner
 * @param  {object}   options The image options
 * @param  {Function} next    Function to call on completion or error
 */
function processImage(options, next) {
   if (fontB === null || fontW === null) {
      // If the fonts aren't ready yet then wait and try again
github silvia-odwyer / Onyx / commands / social / card.js View on Github external
Jimp.read(image, (err, image) => {
        if (err) throw err;

        Jimp.loadFont(Jimp.FONT_SANS_16_WHITE).then(font => {
          image.resize(300, 300);

          image.print(font, 20, 150, `To: ${receiver}`);
          image.print(font, 20, 200, `From: ${sender.username}`);
          image.print(font, 20, 240, `Message: ${message}`);

          image.write("./card.jpg"); // save

          msg.channel.send(`${receiver} just received a card!`, {
            files: ["./card.jpg"]
          });
        });
      });
    }
github CODAIT / node-red-contrib-model-asset-exchange / utils / index.js View on Github external
const getScaledFont = (width, color) => {
  if (width > 1600)
    return color === 'black' ? Jimp.FONT_SANS_128_BLACK : Jimp.FONT_SANS_128_WHITE;
  else if (width > 700)
    return color === 'black' ? Jimp.FONT_SANS_32_BLACK : Jimp.FONT_SANS_32_WHITE;
  else
  return color === 'black' ? Jimp.FONT_SANS_16_BLACK : Jimp.FONT_SANS_16_WHITE;
}
github ryan-rowland / albion-guildbot / src / createImage.js View on Github external
'use strict';

const Jimp = require('jimp');
const config = require('../config');

const FONT_SIZE = 32;
const ITEM_SIZE = 60;

const fontPromise = Jimp.loadFont(Jimp.FONT_SANS_16_WHITE);
const iconsPromise = Jimp.read('https://assets.albiononline.com/assets/images/killboard/fame-list__icons.png').then(image => {
  const fame = image.clone();
  fame.crop(0, 0, 100, 100);
  image.crop(110, 0, 100, 100);
  return { fame, swords: image };
});

function getItemUrl(item) {
  return item && [
    'https://gameinfo.albiononline.com/api/gameinfo/items/',
    `${item.Type}.png`,
    `?count=${item.Count}`,
    `&quality=${item.Quality}`,
  ].join('');
}
github NGRP / node-red-contrib-viseo / node-red-contrib-jimp / node-jimp.js View on Github external
old_h = image.bitmap.height;
            w = (old_w > old_h) ? Jimp.AUTO : 400;
            h = (old_w < old_h) ? Jimp.AUTO : 400;

            try { image.resize(w, h); }
            catch (err) {
                node.error(err);
                return node.send([null, data])
            }

            w = image.bitmap.width;
            h = image.bitmap.height;
        }

        try {
            font_white = await Jimp.loadFont(Jimp.FONT_SANS_16_WHITE);
            font_black = await Jimp.loadFont(Jimp.FONT_SANS_16_BLACK);
        }
        catch (err) {
            node.error(err);
            return node.send([null, data])
        }

        for (let face of drawRect) {
            if (!face.top || !face.left || !face.width || !face.height) {
                throw TypeError("Some of the Rectangle object properties are missing, eg: top, left, width and/or height.");
            }
            if (drawLogo) {
                face.top = Math.round(face.top * (h/old_h));
                face.left = Math.round(face.left * (w/old_w));
                face.width = Math.round(face.width * (w/old_w));
                face.height = Math.round(face.height* (h/old_h));
github ameerthehacker / better-default-avatar / src / utils.js View on Github external
getFont(bestFontSize) {
    switch (bestFontSize) {
      case 8:
        return Jimp.FONT_SANS_8_WHITE;
      case 16:
        return Jimp.FONT_SANS_16_WHITE;
      case 32:
        return Jimp.FONT_SANS_32_WHITE;
      case 64:
        return Jimp.FONT_SANS_64_WHITE;
      case 128:
        return Jimp.FONT_SANS_128_WHITE;
    }
  },
  getMime(mime) {