Socket
Socket
Sign inDemoInstall

instant-meme

Package Overview
Dependencies
122
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.2 to 2.4.0

28

api/memebuilder.js

@@ -25,2 +25,3 @@ const { createCanvas, loadImage, registerFont } = require('canvas')

//write the lines
if(lines[0].length = 0) lines.shift;
for(let index in lines){

@@ -33,2 +34,25 @@ let line = lines[index].trim();

/** Writes watermark to canvas, iff env variable INSTANT_MEME_WATERMARK
*
* @param {CanvasRenderingContext2D} context Canvase contex to be written to.
* @param {String} font_family Name of the font to use when writing watermark.
*/
function addWatermark(context) {
const watermark = process.env.INSTANT_MEME_WATERMARK;
if(!watermark) return;
//get half size font.
const font_original = context.font;
const font_half_height = Number(font_original.replace(/\D/g,''))/2;
const font_half = font_half_height + font_original.replace(/^\d+/,'');
//get text postion
context.font = font_half;
const measurements = context.measureText(watermark);
const x = context.canvas.width - (measurements.width+5);
const y = context.canvas.height - (font_half_height);
//writing
context.fillText(watermark,x,y);
//cleanup
context.font = font_original;
}
/**

@@ -45,3 +69,3 @@ *

const ctx = canvas.getContext('2d');
ctx.font = `${templateData.font_size} "daFont"`;
ctx.font = `${templateData.font_size} daFont`;
ctx.drawImage(image,0,0);

@@ -52,4 +76,4 @@ for(textData of Object.values(templateData.texts)) {

wraptext(ctx,text,x,y,maxwidth,templateData.font_size);
// ctx.fillText(text,x,y,maxwidth);
}
addWatermark(ctx);
return canvas.toBuffer();

@@ -56,0 +80,0 @@ }

2

package.json
{
"name": "instant-meme",
"version": "2.3.2",
"version": "2.4.0",
"description": "A express middleware to build 'memes' on the fly by specifying the image and text content in the url. Because photoshop is to slow for conversation.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,6 @@ # Instant Meme

#### Optional Environmental Variables
- INSTANT_MEME_WATERMARK : string, if set, will add a watermark to the lower right hand corner of the image.
#### Create Assets Directory

@@ -25,0 +29,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc