node-img-placeholder
Advanced tools
Comparing version 0.0.1 to 0.1.2
@@ -10,4 +10,4 @@ var gm = require('gm').subClass({ imageMagick: true }); | ||
imageType: "png", | ||
bg_color: "e1e1e1", | ||
fg_color: "181818" | ||
bgColor: "e1e1e1", | ||
color: "181818" | ||
}; | ||
@@ -20,3 +20,3 @@ | ||
module.exports = function(app){ | ||
app.get('/gen/:dimension.:imageType?/:fg_color?/:bg_color?/:text?', function(req, res, next) { | ||
app.get('/gen/:dimension.:imageType', function(req, res, next) { | ||
var dim = req.params.dimension.split('x'); | ||
@@ -34,6 +34,6 @@ var width, height, foreground, background, imageType, text; | ||
if(typeof req.params.fg_color !== 'undefined') { | ||
foreground = req.params.fg_color; | ||
if(typeof req.query.color !== 'undefined') { | ||
foreground = req.query.color; | ||
} else { | ||
foreground = defaults.fg_color; | ||
foreground = defaults.color; | ||
} | ||
@@ -43,6 +43,6 @@ if(foreground[0] !== '#') foreground = '#' + foreground; | ||
if(typeof req.params.bg_color !== 'undefined') { | ||
background = req.params.bg_color; | ||
if(typeof req.query.bg !== 'undefined') { | ||
background = req.query.bg; | ||
} else { | ||
background = defaults.bg_color; | ||
background = defaults.bgColor; | ||
} | ||
@@ -59,6 +59,6 @@ if(background[0] !== '#') background = '#' + background; | ||
if(typeof req.params.text !== 'undefined') { | ||
if(typeof req.query.text !== 'undefined') { | ||
// TODO handle case when the text is too long for the image | ||
//text = req.params.text; | ||
text = width + " x " + height; | ||
text = req.query.text; | ||
//text = width + " x " + height; | ||
} else { | ||
@@ -74,2 +74,3 @@ text = width + " x " + height; | ||
gm(width, height, background) | ||
.fill(foreground) | ||
.font("Arial", 20) | ||
@@ -76,0 +77,0 @@ .drawText(0, 0, text, "center") |
{ | ||
"name": "node-img-placeholder", | ||
"version": "0.0.1", | ||
"version": "0.1.2", | ||
"description": "run a local image placeholder service", | ||
@@ -5,0 +5,0 @@ "main": "app.js", |
@@ -1,3 +0,5 @@ | ||
# LIPS _(local image placeholder service)_ | ||
# LIPS | ||
> local image placeholder service | ||
## Install dependencies | ||
@@ -33,3 +35,3 @@ First download and install [GraphicsMagick](http://www.graphicsmagick.org/) or [ImageMagick](http://www.imagemagick.org/) and [Ghostscript](http://www.ghostscript.com/). In Mac OS X, you can simply use [Homebrew](http://mxcl.github.io/homebrew/) and do: | ||
The url pattern is: | ||
http://localhost/gen/:dimension.:imageType?/:fg_color?/:bg_color?/ | ||
http://localhost:3000/gen/550x250.png?color=000000&bg=bada55&text=[Text] | ||
@@ -36,0 +38,0 @@ |
105
49
6559