Permalink
Browse files

cleaning up lib files

  • Loading branch information...
1 parent b4f1cc2 commit f4613709826d6a1d4030ed75a31f1489d4560438 @goddamnbugs committed May 7, 2011
Showing with 32 additions and 36 deletions.
  1. +32 −36 lib/node-nude.js
View
@@ -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;

0 comments on commit f461370

Please sign in to comment.