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.0.0 to 2.0.1

2

package.json
{
"name": "instant-meme",
"version": "2.0.0",
"version": "2.0.1",
"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",

@@ -6,10 +6,95 @@ # Instant Meme

*Because photoshop is to slow for a conversation.*
*Because photoshop is to slow for conversation.*
## Instant Meme API
This is a REST API with only one endpoint:
**GET** <URL>.???/:image_name*?1=first text field&2=second text field
**GET** <URL>.???/: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.
#### 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
``` 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:
``` javascript
const express = require('express');
const instantMeme = require('instant-meme');
const server = express();
server.use(instantMeme);
server.listen(3000, () => {console.log(`Server Running`);});
```
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