Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added loadByElement function for loading image/video content into the…

… canvas
  • Loading branch information...
commit c8eb68331a763e0016ab8a03601406f08524f697 1 parent ed3aa40
@pa7 authored
View
2  compressed/noworker.nude.min.js
@@ -1 +1 @@
-(function(){Array.prototype.remove=function(b){var c=this.slice(b+1);this.length=b;return this.push.apply(this,c)};var a=(function(){var e=null,o=null,i=[],l=null,s=null,j=function(){e=document.createElement("canvas");e.style.display="none";var t=document.getElementsByTagName("body")[0];t.appendChild(e);o=e.getContext("2d")},f=function(t){s=document.getElementById(t);e.width=s.width;e.height=s.height;i=[],l=null;o.drawImage(s,0,0)},p=function(){var I=o.getImageData(0,0,e.width,e.height),P=I.data,K=[],z=[],R=[],M=e.width,D=-1,J=-1;var A=function(V,U){D=V;J=U;var u=R.length,x=-1,S=-1;while(u--){var y=R[u],T=y.length;while(T--){if(y[T]==V){x=u}if(y[T]==U){S=u}}}if(x!=-1&&S!=-1&&x==S){return}if(x==-1&&S==-1){R.push([V,U]);return}if(x!=-1&&S==-1){R[x].push(U);return}if(x==-1&&S!=-1){R[S].push(V);return}if(x!=-1&&S!=-1&&x!=S){R[x]=R[x].concat(R[S]);R.remove(S);return}};var w=P.length,M=e.width;for(var N=0,G=1;N<w;N+=4,G++){var H=P[N],O=P[N+1],Q=P[N+2],F=(G>M)?((G%M)-1):G,E=(G>M)?(Math.ceil(G/M)-1):1;if(k(H,O,Q)){K.push({id:G,skin:true,region:0,x:F,y:E,checked:false});var v=-1,B=[G-2,(G-M)-2,G-M-1,(G-M)],t=false;for(var L=0;L<4;L++){var C=B[L];if(K[C]&&K[C].skin){if(K[C].region!=v&&v!=-1&&D!=v&&J!=K[C].region){A(v,K[C].region)}v=K[C].region;t=true}}if(!t){K[G-1].region=z.length;z.push([K[G-1]]);continue}else{if(v>-1){if(!z[v]){z[v]=[]}K[G-1].region=v;z[v].push(K[G-1])}}}else{K.push({id:G,skin:false,region:0,x:F,y:E,checked:false})}}g(z,R);n()},g=function(v,y){var w=y.length,A=[];while(w--){var x=y[w],z=x.length;if(!A[w]){A[w]=[]}while(z--){var u=x[z];A[w]=A[w].concat(v[u]);v[u]=[]}}var t=v.length;while(t--){if(v[t].length>0){A.push(v[t])}}q(A)},q=function(t){var v=t.length;for(var u=0;u<v;u++){if(t[u].length>30){i.push(t[u])}}},n=function(){var v=i.length,t=e.width*e.height,u=0;if(v<3){b(false);return}(function(){var x=false;while(!x){x=true;for(var y=0;y<v-1;y++){if(i[y].length<i[y+1].length){x=false;var w=i[y];i[y]=i[y+1];i[y+1]=w}}}})();while(v--){u+=i[v].length}if((u/t)*100<15){b(false);return}if((i[0].length/u)*100<35&&(i[1].length/u)*100<30&&(i[2].length/u)*100<30){b(false);return}if((i[0].length/u)*100<45){b(false);return}if(i.length>60){b(false);return}b(true)},b=function(t){if(l){l(t)}else{if(t){console.log("the picture contains nudity")}}},h=function(){var v=i.length;for(var y=0;y<v;y++){var A=i[y],x=A.length,w=Math.ceil(Math.random()*255),B=Math.ceil(Math.random()*255),C=Math.ceil(Math.random()*255);for(var u=0;u<x;u++){var t=o.getImageData(A[u].x,A[u].y,1,1),z=t.data;z[0]=w;z[1]=B;z[2]=C;t.data=z;o.putImageData(t,A[u].x,A[u].y)}}},k=function(t,z,D){var A=((t>95)&&(z>40&&z<100)&&(D>20)&&((Math.max(t,z,D)-Math.min(t,z,D))>15)&&(Math.abs(t-z)>15)&&(t>z)&&(t>D)),B=d(t,z,D),E=B[0],u=B[1],y=B[2],C=(((E/u)>1.185)&&(((t*D)/(Math.pow(t+z+D,2)))>0.107)&&(((t*z)/(Math.pow(t+z+D,2)))>0.112)),x=c(t,z,D),w=x[0],F=x[1],v=(w>0&&w<35&&F>0.23&&F<0.68);return(A||C||v)},r=function(x,w,u){x/=255,w/=255,u/=255;var z=0.299*x+0.587*w+0.114*u,v=x-z,t=u-z;return[z,v,t]},m=function(v,u,t){return[Math.acos((0.5*((v-u)+(v-t)))/(Math.sqrt((Math.pow((v-u),2)+((v-t)*(u-t)))))),1-(3*((Math.min(v,u,t))/(v+u+t))),(1/3)*(v+u+t)]},c=function(x,w,t){var v=0,z=Math.max(x,w,t),y=Math.min(x,w,t),u=z-y;if(z==x){v=(w-t)/u}else{if(z==w){v=2+((w-x)/u)}else{v=4+((x-w)/u)}}v=v*60;if(v<0){v=v+360}return[v,1-(3*((Math.min(x,w,t))/(x+w+t))),(1/3)*(x+w+t)]},d=function(w,v,t){var u=w+v+t;return[(w/u),(v/u),(t/u)]};return{init:function(){j()},load:function(t){f(t)},scan:function(t){if(arguments.length>0&&typeof(arguments[0])=="function"){l=t}p()}}})();window.nude=a;a.init()})();
+(function(){Array.prototype.remove=function(b){var c=this.slice(b+1);this.length=b;return this.push.apply(this,c)};var a=(function(){var f=null,p=null,j=[],m=null,t=null,k=function(){f=document.createElement("canvas");f.style.display="none";var u=document.getElementsByTagName("body")[0];u.appendChild(f);p=f.getContext("2d")},b=function(v){var u=document.getElementById(v);f.width=u.width;f.height=u.height;m=null;p.drawImage(u,0,0)},g=function(u){f.width=u.width;f.height=u.height;m=null;p.drawImage(u,0,0)},q=function(){var J=p.getImageData(0,0,f.width,f.height),Q=J.data,L=[],A=[],S=[],N=f.width,E=-1,K=-1;var B=function(W,V){E=W;K=V;var u=S.length,x=-1,T=-1;while(u--){var y=S[u],U=y.length;while(U--){if(y[U]==W){x=u}if(y[U]==V){T=u}}}if(x!=-1&&T!=-1&&x==T){return}if(x==-1&&T==-1){S.push([W,V]);return}if(x!=-1&&T==-1){S[x].push(V);return}if(x==-1&&T!=-1){S[T].push(W);return}if(x!=-1&&T!=-1&&x!=T){S[x]=S[x].concat(S[T]);S.remove(T);return}};var z=Q.length,N=f.width;for(var O=0,H=1;O<z;O+=4,H++){var I=Q[O],P=Q[O+1],R=Q[O+2],G=(H>N)?((H%N)-1):H,F=(H>N)?(Math.ceil(H/N)-1):1;if(l(I,P,R)){L.push({id:H,skin:true,region:0,x:G,y:F,checked:false});var w=-1,C=[H-2,(H-N)-2,H-N-1,(H-N)],v=false;for(var M=0;M<4;M++){var D=C[M];if(L[D]&&L[D].skin){if(L[D].region!=w&&w!=-1&&E!=w&&K!=L[D].region){B(w,L[D].region)}w=L[D].region;v=true}}if(!v){L[H-1].region=A.length;A.push([L[H-1]]);continue}else{if(w>-1){if(!A[w]){A[w]=[]}L[H-1].region=w;A[w].push(L[H-1])}}}else{L.push({id:H,skin:false,region:0,x:G,y:F,checked:false})}}h(A,S);o()},h=function(w,z){var x=z.length,B=[];while(x--){var y=z[x],A=y.length;if(!B[x]){B[x]=[]}while(A--){var v=y[A];B[x]=B[x].concat(w[v]);w[v]=[]}}var u=w.length;while(u--){if(w[u].length>0){B.push(w[u])}}r(B)},r=function(u){var w=u.length;for(var v=0;v<w;v++){if(u[v].length>30){j.push(u[v])}}},o=function(){var w=j.length,u=f.width*f.height,v=0;if(w<3){c(false);return}(function(){var y=false;while(!y){y=true;for(var z=0;z<w-1;z++){if(j[z].length<j[z+1].length){y=false;var x=j[z];j[z]=j[z+1];j[z+1]=x}}}})();while(w--){v+=j[w].length}if((v/u)*100<15){c(false);return}if((j[0].length/v)*100<35&&(j[1].length/v)*100<30&&(j[2].length/v)*100<30){c(false);return}if((j[0].length/v)*100<45){c(false);return}if(j.length>60){c(false);return}c(true)},c=function(u){if(m){m(u)}else{if(u){console.log("the picture contains nudity")}}},i=function(){var w=j.length;for(var z=0;z<w;z++){var B=j[z],y=B.length,x=Math.ceil(Math.random()*255),C=Math.ceil(Math.random()*255),D=Math.ceil(Math.random()*255);for(var v=0;v<y;v++){var u=p.getImageData(B[v].x,B[v].y,1,1),A=u.data;A[0]=x;A[1]=C;A[2]=D;u.data=A;p.putImageData(u,B[v].x,B[v].y)}}},l=function(u,A,E){var B=((u>95)&&(A>40&&A<100)&&(E>20)&&((Math.max(u,A,E)-Math.min(u,A,E))>15)&&(Math.abs(u-A)>15)&&(u>A)&&(u>E)),C=e(u,A,E),F=C[0],v=C[1],z=C[2],D=(((F/v)>1.185)&&(((u*E)/(Math.pow(u+A+E,2)))>0.107)&&(((u*A)/(Math.pow(u+A+E,2)))>0.112)),y=d(u,A,E),x=y[0],G=y[1],w=(x>0&&x<35&&G>0.23&&G<0.68);return(B||D||w)},s=function(z,x,v){z/=255,x/=255,v/=255;var A=0.299*z+0.587*x+0.114*v,w=z-A,u=v-A;return[A,w,u]},n=function(w,v,u){return[Math.acos((0.5*((w-v)+(w-u)))/(Math.sqrt((Math.pow((w-v),2)+((w-u)*(v-u)))))),1-(3*((Math.min(w,v,u))/(w+v+u))),(1/3)*(w+v+u)]},d=function(y,x,u){var w=0,A=Math.max(y,x,u),z=Math.min(y,x,u),v=A-z;if(A==y){w=(x-u)/v}else{if(A==x){w=2+((x-y)/v)}else{w=4+((y-x)/v)}}w=w*60;if(w<0){w=w+360}return[w,1-(3*((Math.min(y,x,u))/(y+x+u))),(1/3)*(y+x+u)]},e=function(x,w,u){var v=x+w+u;return[(x/v),(w/v),(u/v)]};return{init:function(){k()},load:function(u){if(typeof(u)=="string"){b(u)}else{g(u)}},scan:function(u){if(arguments.length>0&&typeof(arguments[0])=="function"){m=u}q()}}})();window.nude=a;a.init()})();
View
2  compressed/nude.min.js
@@ -1 +1 @@
-(function(){var a=(function(){var e=null,c=null,g=null,d=function(){e=document.createElement("canvas");e.style.display="none";var i=document.getElementsByTagName("body")[0];i.appendChild(e);c=e.getContext("2d")},b=function(j){var i=document.getElementById(j);e.width=i.width;e.height=i.height;g=null;c.drawImage(i,0,0)},h=function(){var k=c.getImageData(0,0,e.width,e.height),l=k.data;var i=new Worker("worker.nude.js"),j=[l,e.width,e.height];i.postMessage(j);i.onmessage=function(m){f(m.data)}},f=function(i){if(g){g(i)}else{if(i){console.log("the picture contains nudity")}}};return{init:function(){d();if(!!!window.Worker){document.write(unescape("%3Cscript src='noworker.nude.js' type='text/javascript'%3E%3C/script%3E"))}},load:function(i){b(i)},scan:function(i){if(arguments.length>0&&typeof(arguments[0])=="function"){g=i}h()}}})();if(!window.nude){window.nude=a}a.init()})();
+(function(){var a=(function(){var e=null,c=null,h=null,d=function(){e=document.createElement("canvas");e.style.display="none";var j=document.getElementsByTagName("body")[0];j.appendChild(e);c=e.getContext("2d")},b=function(k){var j=document.getElementById(k);e.width=j.width;e.height=j.height;h=null;c.drawImage(j,0,0)},g=function(j){e.width=j.width;e.height=j.height;h=null;c.drawImage(j,0,0)},i=function(){var l=c.getImageData(0,0,e.width,e.height),m=l.data;var j=new Worker("worker.nude.js"),k=[m,e.width,e.height];j.postMessage(k);j.onmessage=function(n){f(n.data)}},f=function(j){if(h){h(j)}else{if(j){console.log("the picture contains nudity")}}};return{init:function(){d();if(!!!window.Worker){document.write(unescape("%3Cscript src='noworker.nude.js' type='text/javascript'%3E%3C/script%3E"))}},load:function(j){if(typeof(j)=="string"){b(j)}else{g(j)}},scan:function(j){if(arguments.length>0&&typeof(arguments[0])=="function"){h=j}i()}}})();if(!window.nude){window.nude=a}a.init()})();
View
31 noworker.nude.js
@@ -28,18 +28,27 @@
b.appendChild(canvas);
ctx = canvas.getContext("2d");
},
- loadImage = function(id){
-
- img = document.getElementById(id);
+ loadImageById = function(id){
+ // get the image
+ var img = document.getElementById(id);
+ // apply the width and height to the canvas element
canvas.width = img.width;
canvas.height = img.height;
- // reset the arrays
- skinRegions = [],
+ // reset the result function
resultFn = null;
// draw the image into the canvas element
ctx.drawImage(img, 0, 0);
-
-
+
+ },
+ loadImageByElement = function(element){
+ // apply width and height to the canvas element
+ // make sure you set width and height at the element
+ canvas.width = element.width;
+ canvas.height = element.height;
+ // reset result function
+ resultFn = null;
+ // draw the image/video element into the canvas
+ ctx.drawImage(element, 0, 0);
},
scanImage = function(){
// get the image data
@@ -425,8 +434,12 @@
init: function(){
initCanvas();
},
- load: function(id){
- loadImage(id);
+ load: function(param){
+ if(typeof(param) == "string"){
+ loadImageById(param);
+ }else{
+ loadImageByElement(param);
+ }
},
scan: function(fn){
if(arguments.length>0 && typeof(arguments[0]) == "function"){
View
16 nude.js
@@ -33,6 +33,16 @@
ctx.drawImage(img, 0, 0);
},
+ loadImageByElement = function(element){
+ // apply width and height to the canvas element
+ // make sure you set width and height at the element
+ canvas.width = element.width;
+ canvas.height = element.height;
+ // reset result function
+ resultFn = null;
+ // draw the image/video element into the canvas
+ ctx.drawImage(element, 0, 0);
+ },
scanImage = function(){
// get the image data
var image = ctx.getImageData(0, 0, canvas.width, canvas.height),
@@ -69,7 +79,11 @@
},
load: function(param){
- loadImageById(param);
+ if(typeof(param) == "string"){
+ loadImageById(param);
+ }else{
+ loadImageByElement(param);
+ }
},
scan: function(fn){
if(arguments.length>0 && typeof(arguments[0]) == "function"){
View
2  tests/noworker.nude.min.js
@@ -1 +1 @@
-(function(){Array.prototype.remove=function(b){var c=this.slice(b+1);this.length=b;return this.push.apply(this,c)};var a=(function(){var e=null,o=null,i=[],l=null,s=null,j=function(){e=document.createElement("canvas");e.style.display="none";var t=document.getElementsByTagName("body")[0];t.appendChild(e);o=e.getContext("2d")},f=function(t){s=document.getElementById(t);e.width=s.width;e.height=s.height;i=[],l=null;o.drawImage(s,0,0)},p=function(){var I=o.getImageData(0,0,e.width,e.height),P=I.data,K=[],z=[],R=[],M=e.width,D=-1,J=-1;var A=function(V,U){D=V;J=U;var u=R.length,x=-1,S=-1;while(u--){var y=R[u],T=y.length;while(T--){if(y[T]==V){x=u}if(y[T]==U){S=u}}}if(x!=-1&&S!=-1&&x==S){return}if(x==-1&&S==-1){R.push([V,U]);return}if(x!=-1&&S==-1){R[x].push(U);return}if(x==-1&&S!=-1){R[S].push(V);return}if(x!=-1&&S!=-1&&x!=S){R[x]=R[x].concat(R[S]);R.remove(S);return}};var w=P.length,M=e.width;for(var N=0,G=1;N<w;N+=4,G++){var H=P[N],O=P[N+1],Q=P[N+2],F=(G>M)?((G%M)-1):G,E=(G>M)?(Math.ceil(G/M)-1):1;if(k(H,O,Q)){K.push({id:G,skin:true,region:0,x:F,y:E,checked:false});var v=-1,B=[G-2,(G-M)-2,G-M-1,(G-M)],t=false;for(var L=0;L<4;L++){var C=B[L];if(K[C]&&K[C].skin){if(K[C].region!=v&&v!=-1&&D!=v&&J!=K[C].region){A(v,K[C].region)}v=K[C].region;t=true}}if(!t){K[G-1].region=z.length;z.push([K[G-1]]);continue}else{if(v>-1){if(!z[v]){z[v]=[]}K[G-1].region=v;z[v].push(K[G-1])}}}else{K.push({id:G,skin:false,region:0,x:F,y:E,checked:false})}}g(z,R);n()},g=function(v,y){var w=y.length,A=[];while(w--){var x=y[w],z=x.length;if(!A[w]){A[w]=[]}while(z--){var u=x[z];A[w]=A[w].concat(v[u]);v[u]=[]}}var t=v.length;while(t--){if(v[t].length>0){A.push(v[t])}}q(A)},q=function(t){var v=t.length;for(var u=0;u<v;u++){if(t[u].length>30){i.push(t[u])}}},n=function(){var v=i.length,t=e.width*e.height,u=0;if(v<3){b(false);return}(function(){var x=false;while(!x){x=true;for(var y=0;y<v-1;y++){if(i[y].length<i[y+1].length){x=false;var w=i[y];i[y]=i[y+1];i[y+1]=w}}}})();while(v--){u+=i[v].length}if((u/t)*100<15){b(false);return}if((i[0].length/u)*100<35&&(i[1].length/u)*100<30&&(i[2].length/u)*100<30){b(false);return}if((i[0].length/u)*100<45){b(false);return}if(i.length>60){b(false);return}b(true)},b=function(t){if(l){l(t)}else{if(t){console.log("the picture contains nudity")}}},h=function(){var v=i.length;for(var y=0;y<v;y++){var A=i[y],x=A.length,w=Math.ceil(Math.random()*255),B=Math.ceil(Math.random()*255),C=Math.ceil(Math.random()*255);for(var u=0;u<x;u++){var t=o.getImageData(A[u].x,A[u].y,1,1),z=t.data;z[0]=w;z[1]=B;z[2]=C;t.data=z;o.putImageData(t,A[u].x,A[u].y)}}},k=function(t,z,D){var A=((t>95)&&(z>40&&z<100)&&(D>20)&&((Math.max(t,z,D)-Math.min(t,z,D))>15)&&(Math.abs(t-z)>15)&&(t>z)&&(t>D)),B=d(t,z,D),E=B[0],u=B[1],y=B[2],C=(((E/u)>1.185)&&(((t*D)/(Math.pow(t+z+D,2)))>0.107)&&(((t*z)/(Math.pow(t+z+D,2)))>0.112)),x=c(t,z,D),w=x[0],F=x[1],v=(w>0&&w<35&&F>0.23&&F<0.68);return(A||C||v)},r=function(x,w,u){x/=255,w/=255,u/=255;var z=0.299*x+0.587*w+0.114*u,v=x-z,t=u-z;return[z,v,t]},m=function(v,u,t){return[Math.acos((0.5*((v-u)+(v-t)))/(Math.sqrt((Math.pow((v-u),2)+((v-t)*(u-t)))))),1-(3*((Math.min(v,u,t))/(v+u+t))),(1/3)*(v+u+t)]},c=function(x,w,t){var v=0,z=Math.max(x,w,t),y=Math.min(x,w,t),u=z-y;if(z==x){v=(w-t)/u}else{if(z==w){v=2+((w-x)/u)}else{v=4+((x-w)/u)}}v=v*60;if(v<0){v=v+360}return[v,1-(3*((Math.min(x,w,t))/(x+w+t))),(1/3)*(x+w+t)]},d=function(w,v,t){var u=w+v+t;return[(w/u),(v/u),(t/u)]};return{init:function(){j()},load:function(t){f(t)},scan:function(t){if(arguments.length>0&&typeof(arguments[0])=="function"){l=t}p()}}})();window.nude=a;a.init()})();
+(function(){Array.prototype.remove=function(b){var c=this.slice(b+1);this.length=b;return this.push.apply(this,c)};var a=(function(){var f=null,p=null,j=[],m=null,t=null,k=function(){f=document.createElement("canvas");f.style.display="none";var u=document.getElementsByTagName("body")[0];u.appendChild(f);p=f.getContext("2d")},b=function(v){var u=document.getElementById(v);f.width=u.width;f.height=u.height;m=null;p.drawImage(u,0,0)},g=function(u){f.width=u.width;f.height=u.height;m=null;p.drawImage(u,0,0)},q=function(){var J=p.getImageData(0,0,f.width,f.height),Q=J.data,L=[],A=[],S=[],N=f.width,E=-1,K=-1;var B=function(W,V){E=W;K=V;var u=S.length,x=-1,T=-1;while(u--){var y=S[u],U=y.length;while(U--){if(y[U]==W){x=u}if(y[U]==V){T=u}}}if(x!=-1&&T!=-1&&x==T){return}if(x==-1&&T==-1){S.push([W,V]);return}if(x!=-1&&T==-1){S[x].push(V);return}if(x==-1&&T!=-1){S[T].push(W);return}if(x!=-1&&T!=-1&&x!=T){S[x]=S[x].concat(S[T]);S.remove(T);return}};var z=Q.length,N=f.width;for(var O=0,H=1;O<z;O+=4,H++){var I=Q[O],P=Q[O+1],R=Q[O+2],G=(H>N)?((H%N)-1):H,F=(H>N)?(Math.ceil(H/N)-1):1;if(l(I,P,R)){L.push({id:H,skin:true,region:0,x:G,y:F,checked:false});var w=-1,C=[H-2,(H-N)-2,H-N-1,(H-N)],v=false;for(var M=0;M<4;M++){var D=C[M];if(L[D]&&L[D].skin){if(L[D].region!=w&&w!=-1&&E!=w&&K!=L[D].region){B(w,L[D].region)}w=L[D].region;v=true}}if(!v){L[H-1].region=A.length;A.push([L[H-1]]);continue}else{if(w>-1){if(!A[w]){A[w]=[]}L[H-1].region=w;A[w].push(L[H-1])}}}else{L.push({id:H,skin:false,region:0,x:G,y:F,checked:false})}}h(A,S);o()},h=function(w,z){var x=z.length,B=[];while(x--){var y=z[x],A=y.length;if(!B[x]){B[x]=[]}while(A--){var v=y[A];B[x]=B[x].concat(w[v]);w[v]=[]}}var u=w.length;while(u--){if(w[u].length>0){B.push(w[u])}}r(B)},r=function(u){var w=u.length;for(var v=0;v<w;v++){if(u[v].length>30){j.push(u[v])}}},o=function(){var w=j.length,u=f.width*f.height,v=0;if(w<3){c(false);return}(function(){var y=false;while(!y){y=true;for(var z=0;z<w-1;z++){if(j[z].length<j[z+1].length){y=false;var x=j[z];j[z]=j[z+1];j[z+1]=x}}}})();while(w--){v+=j[w].length}if((v/u)*100<15){c(false);return}if((j[0].length/v)*100<35&&(j[1].length/v)*100<30&&(j[2].length/v)*100<30){c(false);return}if((j[0].length/v)*100<45){c(false);return}if(j.length>60){c(false);return}c(true)},c=function(u){if(m){m(u)}else{if(u){console.log("the picture contains nudity")}}},i=function(){var w=j.length;for(var z=0;z<w;z++){var B=j[z],y=B.length,x=Math.ceil(Math.random()*255),C=Math.ceil(Math.random()*255),D=Math.ceil(Math.random()*255);for(var v=0;v<y;v++){var u=p.getImageData(B[v].x,B[v].y,1,1),A=u.data;A[0]=x;A[1]=C;A[2]=D;u.data=A;p.putImageData(u,B[v].x,B[v].y)}}},l=function(u,A,E){var B=((u>95)&&(A>40&&A<100)&&(E>20)&&((Math.max(u,A,E)-Math.min(u,A,E))>15)&&(Math.abs(u-A)>15)&&(u>A)&&(u>E)),C=e(u,A,E),F=C[0],v=C[1],z=C[2],D=(((F/v)>1.185)&&(((u*E)/(Math.pow(u+A+E,2)))>0.107)&&(((u*A)/(Math.pow(u+A+E,2)))>0.112)),y=d(u,A,E),x=y[0],G=y[1],w=(x>0&&x<35&&G>0.23&&G<0.68);return(B||D||w)},s=function(z,x,v){z/=255,x/=255,v/=255;var A=0.299*z+0.587*x+0.114*v,w=z-A,u=v-A;return[A,w,u]},n=function(w,v,u){return[Math.acos((0.5*((w-v)+(w-u)))/(Math.sqrt((Math.pow((w-v),2)+((w-u)*(v-u)))))),1-(3*((Math.min(w,v,u))/(w+v+u))),(1/3)*(w+v+u)]},d=function(y,x,u){var w=0,A=Math.max(y,x,u),z=Math.min(y,x,u),v=A-z;if(A==y){w=(x-u)/v}else{if(A==x){w=2+((x-y)/v)}else{w=4+((y-x)/v)}}w=w*60;if(w<0){w=w+360}return[w,1-(3*((Math.min(y,x,u))/(y+x+u))),(1/3)*(y+x+u)]},e=function(x,w,u){var v=x+w+u;return[(x/v),(w/v),(u/v)]};return{init:function(){k()},load:function(u){if(typeof(u)=="string"){b(u)}else{g(u)}},scan:function(u){if(arguments.length>0&&typeof(arguments[0])=="function"){m=u}q()}}})();window.nude=a;a.init()})();
View
2  tests/nude.min.js
@@ -1 +1 @@
-(function(){var a=(function(){var e=null,c=null,g=null,d=function(){e=document.createElement("canvas");e.style.display="none";var i=document.getElementsByTagName("body")[0];i.appendChild(e);c=e.getContext("2d")},b=function(j){var i=document.getElementById(j);e.width=i.width;e.height=i.height;g=null;c.drawImage(i,0,0)},h=function(){var k=c.getImageData(0,0,e.width,e.height),l=k.data;var i=new Worker("worker.nude.js"),j=[l,e.width,e.height];i.postMessage(j);i.onmessage=function(m){f(m.data)}},f=function(i){if(g){g(i)}else{if(i){console.log("the picture contains nudity")}}};return{init:function(){d();if(!!!window.Worker){document.write(unescape("%3Cscript src='noworker.nude.js' type='text/javascript'%3E%3C/script%3E"))}},load:function(i){b(i)},scan:function(i){if(arguments.length>0&&typeof(arguments[0])=="function"){g=i}h()}}})();if(!window.nude){window.nude=a}a.init()})();
+(function(){var a=(function(){var e=null,c=null,h=null,d=function(){e=document.createElement("canvas");e.style.display="none";var j=document.getElementsByTagName("body")[0];j.appendChild(e);c=e.getContext("2d")},b=function(k){var j=document.getElementById(k);e.width=j.width;e.height=j.height;h=null;c.drawImage(j,0,0)},g=function(j){e.width=j.width;e.height=j.height;h=null;c.drawImage(j,0,0)},i=function(){var l=c.getImageData(0,0,e.width,e.height),m=l.data;var j=new Worker("worker.nude.js"),k=[m,e.width,e.height];j.postMessage(k);j.onmessage=function(n){f(n.data)}},f=function(j){if(h){h(j)}else{if(j){console.log("the picture contains nudity")}}};return{init:function(){d();if(!!!window.Worker){document.write(unescape("%3Cscript src='noworker.nude.js' type='text/javascript'%3E%3C/script%3E"))}},load:function(j){if(typeof(j)=="string"){b(j)}else{g(j)}},scan:function(j){if(arguments.length>0&&typeof(arguments[0])=="function"){h=j}i()}}})();if(!window.nude){window.nude=a}a.init()})();
Please sign in to comment.
Something went wrong with that request. Please try again.