Last active
August 29, 2015 14:14
-
-
Save Eckankar/74b255a35620f40b10f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Reimar Your Life | |
| // @namespace http://mathemaniac.org | |
| // @version 1.0 | |
| // @description Johnny Reimar. | |
| // @include https://* | |
| // @include http://* | |
| // @copyright 2015, Sebastian Paaske Tørholm | |
| // @require https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js | |
| // @require https://github.com/jaysalvat/jquery.facedetection/raw/master/dist/jquery.facedetection.min.js | |
| // @require http://brohr.coq.dk/reimar/reimar.datauri.js | |
| // ==/UserScript== | |
| function convertImageToCanvas(image) { | |
| var canvas = document.createElement("canvas"); | |
| canvas.width = image.width; | |
| canvas.height = image.height; | |
| canvas.getContext("2d").drawImage(image, 0, 0); | |
| $(image).replaceWith(canvas); | |
| return canvas.getContext("2d"); | |
| } | |
| $('img').each(function () { | |
| var that = this; | |
| try { | |
| $(that).faceDetection({ | |
| complete: function (faces) { | |
| var that = this; | |
| console.log(faces); | |
| if (faces.length > 0) { | |
| var reimar = new Image; | |
| reimar.addEventListener("load", function () { | |
| var canvas = convertImageToCanvas(that[0]); | |
| for (var i = 0; i < faces.length; i++) { | |
| var face = faces[i]; | |
| console.log("face ", i, ": ", face); | |
| canvas.drawImage(reimar, face.x, face.y, face.width, face.height); | |
| } | |
| }, false); | |
| reimar.src = REIMAR_URI; | |
| } | |
| } | |
| }); | |
| } catch (ex) { console.log(ex); }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment