Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit bf4916cdcea9e5dc03804bbd1207ae2af4bebf88 0 parents
@aheckmann authored
3  .gitignore
@@ -0,0 +1,3 @@
+node_modules/
+*.swp
+*.swo
1  Procfile
@@ -0,0 +1 @@
+web: node app.js
28 app.js
@@ -0,0 +1,28 @@
+
+var gm = require('gm')
+ , connect = require('connect')
+
+connect(
+ connect.logger()
+ , connect.query()
+ , connect.bodyParser()
+ , handler
+ , connect.errorHandler({ showStack: true })
+).listen(8900);
+console.error('listening on http://localhost:8900');
+
+var ops = require('./ops');
+
+function handler (req, res, next) {
+ var op = req.query.op;
+ if ('string' !== typeof op) op = '';
+ op = op.trim();
+ console.error('trying method %s', op);
+
+ var fn = ops[op];
+ console.error('fn?', !!fn);
+
+ if (!fn) return next();
+
+ fn(req, res, next);
+}
BIN  nodejs.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 ops.js
@@ -0,0 +1,121 @@
+var img = __dirname + '/nodejs.png';
+
+var resizeX = 343
+ , resizeY = 257
+
+var gm = require('gm')
+
+
+exports['resize'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['rotate'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .rotate('green', -25)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['rotate-edge'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .rotate('green', -25)
+ .edge(3)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+
+exports['flip-rotate-edge'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .flip()
+ .rotate('green', -25)
+ .edge(3)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+
+exports['blur'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .blur(30, 20)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+
+exports['implode'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .implode(-1.2)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+
+exports['contrast'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .contrast(-6)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['colorize'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .colorize(200, 200, 256)
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['equalize'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .equalize()
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['swirl'] = function (req, res, next) {
+ var base =
+ gm(img)
+ .resize(resizeX, resizeY)
+ .region(101, 112, 90, 87)
+ .swirl(200)
+ .autoOrient();
+
+ write(base, res, next);
+}
+exports['sepia']= function (req, res, next) {
+ var base =
+ gm(img)
+ .sepia()
+ .resize(resizeX, resizeY)
+ .autoOrient();
+
+ write(base, res, next);
+}
+
+function write (base, res, next) {
+ base.stream('png', function (err, stdout, stderr) {
+ if (err) return next(err);
+ stdout.pipe(res);
+ });
+}
20 package.json
@@ -0,0 +1,20 @@
+{
+ "author": "Aaron Heckmann <aaronheckmann+github@gmail.com>",
+ "name": "tryit",
+ "description": "gm resizer test spin",
+ "version": "0.0.0",
+ "private": true,
+ "homepage": "http://aheckmann.github.com/gm/",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/gm.git"
+ },
+ "engines": {
+ "node": "~0.4.7"
+ },
+ "dependencies": {
+ "gm": "1.0.1"
+ , "connect": "1.8.4"
+ },
+ "devDependencies": {}
+}
3  todo
@@ -0,0 +1,3 @@
+push to heroku
+install graphicsmagick on heroku
+fix urls in forms to point to heroku
Please sign in to comment.
Something went wrong with that request. Please try again.