Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit

  • Loading branch information...
commit bf4916cdcea9e5dc03804bbd1207ae2af4bebf88 0 parents
Aaron Heckmann authored
3  .gitignore
... ... @@ -0,0 +1,3 @@
  1 +node_modules/
  2 +*.swp
  3 +*.swo
1  Procfile
... ... @@ -0,0 +1 @@
  1 +web: node app.js
28 app.js
... ... @@ -0,0 +1,28 @@
  1 +
  2 +var gm = require('gm')
  3 + , connect = require('connect')
  4 +
  5 +connect(
  6 + connect.logger()
  7 + , connect.query()
  8 + , connect.bodyParser()
  9 + , handler
  10 + , connect.errorHandler({ showStack: true })
  11 +).listen(8900);
  12 +console.error('listening on http://localhost:8900');
  13 +
  14 +var ops = require('./ops');
  15 +
  16 +function handler (req, res, next) {
  17 + var op = req.query.op;
  18 + if ('string' !== typeof op) op = '';
  19 + op = op.trim();
  20 + console.error('trying method %s', op);
  21 +
  22 + var fn = ops[op];
  23 + console.error('fn?', !!fn);
  24 +
  25 + if (!fn) return next();
  26 +
  27 + fn(req, res, next);
  28 +}
BIN  nodejs.png
121 ops.js
... ... @@ -0,0 +1,121 @@
  1 +var img = __dirname + '/nodejs.png';
  2 +
  3 +var resizeX = 343
  4 + , resizeY = 257
  5 +
  6 +var gm = require('gm')
  7 +
  8 +
  9 +exports['resize'] = function (req, res, next) {
  10 + var base =
  11 + gm(img)
  12 + .resize(resizeX, resizeY)
  13 + .autoOrient();
  14 +
  15 + write(base, res, next);
  16 +}
  17 +exports['rotate'] = function (req, res, next) {
  18 + var base =
  19 + gm(img)
  20 + .rotate('green', -25)
  21 + .resize(resizeX, resizeY)
  22 + .autoOrient();
  23 +
  24 + write(base, res, next);
  25 +}
  26 +exports['rotate-edge'] = function (req, res, next) {
  27 + var base =
  28 + gm(img)
  29 + .rotate('green', -25)
  30 + .edge(3)
  31 + .resize(resizeX, resizeY)
  32 + .autoOrient();
  33 +
  34 + write(base, res, next);
  35 +}
  36 +
  37 +exports['flip-rotate-edge'] = function (req, res, next) {
  38 + var base =
  39 + gm(img)
  40 + .flip()
  41 + .rotate('green', -25)
  42 + .edge(3)
  43 + .resize(resizeX, resizeY)
  44 + .autoOrient();
  45 +
  46 + write(base, res, next);
  47 +}
  48 +
  49 +exports['blur'] = function (req, res, next) {
  50 + var base =
  51 + gm(img)
  52 + .blur(30, 20)
  53 + .resize(resizeX, resizeY)
  54 + .autoOrient();
  55 +
  56 + write(base, res, next);
  57 +}
  58 +
  59 +exports['implode'] = function (req, res, next) {
  60 + var base =
  61 + gm(img)
  62 + .implode(-1.2)
  63 + .resize(resizeX, resizeY)
  64 + .autoOrient();
  65 +
  66 + write(base, res, next);
  67 +}
  68 +
  69 +exports['contrast'] = function (req, res, next) {
  70 + var base =
  71 + gm(img)
  72 + .contrast(-6)
  73 + .resize(resizeX, resizeY)
  74 + .autoOrient();
  75 +
  76 + write(base, res, next);
  77 +}
  78 +exports['colorize'] = function (req, res, next) {
  79 + var base =
  80 + gm(img)
  81 + .colorize(200, 200, 256)
  82 + .resize(resizeX, resizeY)
  83 + .autoOrient();
  84 +
  85 + write(base, res, next);
  86 +}
  87 +exports['equalize'] = function (req, res, next) {
  88 + var base =
  89 + gm(img)
  90 + .equalize()
  91 + .resize(resizeX, resizeY)
  92 + .autoOrient();
  93 +
  94 + write(base, res, next);
  95 +}
  96 +exports['swirl'] = function (req, res, next) {
  97 + var base =
  98 + gm(img)
  99 + .resize(resizeX, resizeY)
  100 + .region(101, 112, 90, 87)
  101 + .swirl(200)
  102 + .autoOrient();
  103 +
  104 + write(base, res, next);
  105 +}
  106 +exports['sepia']= function (req, res, next) {
  107 + var base =
  108 + gm(img)
  109 + .sepia()
  110 + .resize(resizeX, resizeY)
  111 + .autoOrient();
  112 +
  113 + write(base, res, next);
  114 +}
  115 +
  116 +function write (base, res, next) {
  117 + base.stream('png', function (err, stdout, stderr) {
  118 + if (err) return next(err);
  119 + stdout.pipe(res);
  120 + });
  121 +}
20 package.json
... ... @@ -0,0 +1,20 @@
  1 +{
  2 + "author": "Aaron Heckmann <aaronheckmann+github@gmail.com>",
  3 + "name": "tryit",
  4 + "description": "gm resizer test spin",
  5 + "version": "0.0.0",
  6 + "private": true,
  7 + "homepage": "http://aheckmann.github.com/gm/",
  8 + "repository": {
  9 + "type": "git",
  10 + "url": "git://github.com/aheckmann/gm.git"
  11 + },
  12 + "engines": {
  13 + "node": "~0.4.7"
  14 + },
  15 + "dependencies": {
  16 + "gm": "1.0.1"
  17 + , "connect": "1.8.4"
  18 + },
  19 + "devDependencies": {}
  20 +}
3  todo
... ... @@ -0,0 +1,3 @@
  1 +push to heroku
  2 +install graphicsmagick on heroku
  3 +fix urls in forms to point to heroku

0 comments on commit bf4916c

Please sign in to comment.
Something went wrong with that request. Please try again.