Skip to content

Commit

Permalink
cleaning up lib files
Browse files Browse the repository at this point in the history
  • Loading branch information
goddamnbugs committed May 7, 2011
1 parent b4f1cc2 commit f461370
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions lib/node-nude.js
@@ -1,52 +1,48 @@
/*
* Nude.js - Nudity detection with Javascript and HTMLCanvas
* node-nude - node.js nudity detection based on nude.js
*
* Author: Patrick Wied ( http://www.patrick-wied.at )
* Version: 0.1 (2010-11-21)
* Author: goddamnbugs ( http://goddamnbugs.com/ ) ; based on Patrick Wied's nude.js ( http://www.patrick-wied.at )
* Version: 0.2 (2011-05-06)
* License: MIT License
*/

var Worker = require('webworker').Worker;
var path = require('path');

var nude = function(){
// private var definition
this.canvas = null;
this.ctx = null;
this.img = null;
this.canvas = null;
this.ctx = null;
this.img = null;
};
nude.prototype.init = function(cnvs){
this.canvas = cnvs;
// the canvas should not be visible
//canvas.style.display = "none";
this.ctx = this.canvas.getContext("2d");
};

this.canvas = cnvs;
this.ctx = this.canvas.getContext("2d");
};
nude.prototype.load = function(image){
this.img = image
this.canvas.width = this.img.width;
this.canvas.height = this.img.height;
//img.setAttribute("style", "visibility:hidden;");
//domPos = getPosition(img);
// draw the image into the canvas element
this.ctx.drawImage(this.img, 0, 0);

};
this.img = image
this.canvas.width = this.img.width;
this.canvas.height = this.img.height;
// draw the image into the canvas element
this.ctx.drawImage(this.img, 0, 0);
};
nude.prototype.scan = function(callback){
// get the image data
var image = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height),
imageData = image.data;
var myWorker = new Worker(path.join(__dirname, 'worker.js')),
message = [imageData, this.canvas.width, this.canvas.height];
myWorker.postMessage(message);
myWorker.onmessage = function(event){
callback(event.data);
myWorker.terminate();
}
};
// get the image data
var image = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height),
imageData = image.data;
var myWorker = new Worker(
path.join(__dirname, 'worker.js')),
message = [imageData, this.canvas.width, this.canvas.height];

myWorker.postMessage(message);
myWorker.onmessage = function(event){
callback(event.data);
myWorker.terminate();
}
};
nude.prototype.isnude = function(filename, callback) {
var Canvas = require('canvas')
, Image = Canvas.Image
, fs = require('fs');
var Canvas = require('canvas');
var Image = Canvas.Image;
var fs = require('fs');

var img = new Image;

Expand Down

0 comments on commit f461370

Please sign in to comment.