npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

instant-meme

v2.4.0

Published

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.

Downloads

4

Readme

Instant Meme

Instant meme is an Express Middlware that allows users to create 'meme' images on the fly by specifying the image template, and desired text in the URL parameters.

Because photoshop is to slow for conversation.

Instant Meme API

This is a REST API with only one endpoint: GET .???/:image_name?t1=first text field&t2=second text field

As you can see, requests follow a simple pattern, with the template identified by a URL parameter immedietly following the endpoint url, and text fields by query parameters.

Installation and Setup

Installation

npm install --save instant-meme

Setup

A little bit more involved.

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

In your project's root directory, create a new directory named "instant-meme".
Inside this directory, create two more directories, named "fonts" and "templates".

The resulting directory tree should look like this.

root┐
    └instant-meme┐
                 ┢fonts
                 └templates

Add Fonts

Place any fonts you intend to use into the fonts directory.

This API has only been tested with true type fonts (.ttf). Use others at your own risk.

Add Empty Meme Images

Add the images that will form the base of your memes to the templates folder.

This API has only been tested with .png images so far. You can try it with other filetypes, but that's the only one officialy supported at the moment.

Any text you plan to overwrite or replace should be absent from these images.

I recomend giving them usefull names, such as 'awkward-penguin.png', rather than 'meme28.png'.

Create Template Definitions

For each meme you plan to serve from this api, create a file in the templates folder named "meme-name.json".

The meme-name is the name that users will call this meme-template by in the URLs they construct.
ie: URL/turtlepower?t1=cowabunga will attempt to call the turtlepower.json template.

These files determine which image will be used, how many text fields it will have, where they are found, and any default text they will contain.

The shape of this JSON file is as follows
turtlepower.json

{
  "template": "an_image_in_this_folder.png",
  "font": "a_font_in_the_fonts_folder.ttf",
  "font_size": "30px",
  "texts" : {
    "t1": {
      "text":"Default text goes here",
      "x": 10,
      "y": 20,
    }
  }
}

This is mostly self explanitory. The texts object needs to be broken down a bit.

The texts object defines each text box on your meme. Each one should be identified by a t<number>. ie: t1, t2, or t1000.

The x an y coordinates are in pixels, with 0,0 being the upper-left corner. X increases to the right, and Y increases downward.

Actualy Using It

Once it's installed and set up, you can add it to the middleware chain of your Express.js server.

For example, the folllowing would be a super simple, but working use of this middleware:

const express = require('express');
const instantMeme = require('instant-meme');
const server = express();

server.use(instantMeme);

server.listen(3000, () => {console.log(`Server Running`);});