ひなったーにな~れ
by
tyage
2010-11-04 [2010/11/04 19:13:20]
canvasとdataURLが使えると顔をひなったーにします。 詳細→ http://hinata.in/blog/20100227231617.html
/*
* @title bookmarklet
* @description my bookmarklet
* @include http://*
* @license MIT License
* @require http://lab.gkbr.me/facedetect/facedetector.min.js
*/
(function(i, max) {
var hinata = new Image();
hinata.src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCABLAEsDASIAAhEBAxEB/8QAHgAAAgMBAAMBAQAAAAAAAAAABwkEBggFAQIKAAP/xAA9EAABAwMCBAMDCQYHAQAAAAABAgMEBQYRAAcIEiExCRNBIlFhFBUWIzJxgZGxChgzgqHBJCVCUlNkctL/xAAbAQACAwEBAQAAAAAAAAAAAAAFBwMEBgECCP/EAC0RAAEDAwIEBAYDAAAAAAAAAAECAxEABAUhMQYSQVEiYXGBBxMVobHRFJLB/9oADAMBAAIRAxEAPwBu3iA2tQrl20oAuCC2/HZu2KCHEBQTzhSMgHIz19QdK5/aQadbm0VQ2ztSzIpZhu06Q8Ap3OV5SD07DpjtponiP1b6P8OJr2cCJclNWTjtl8J/vpVP7T18sqcbZ68Y7KlsrgvtLcA6DPIR+uobQCQTVZLig4hPeaVVNqU1zmmlBSXl8ySr1A1zn6q7DqrctRPI4faye3TU24FGXbFPVEiqS5EW43KIHRQ5spP5H+mq1cLjrdMJB6trweuiiXQasKQqoNXqTr91iW2SQ0SvPw1OhU5V2VYuury0z9YsHuANTLAs6Zd7U6ZBjKdW3CcHIkZP2c51z7IqKoTs5DiTzrgrbwfRQ1AX+dS0jcRUwY5AhatjNTPlTU2pxoLTYxG5iCP11DmuJ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tuO6k8oyonprjXFuHHg86EuOJcWsudV9yev5ap0zcGbUIq3/AC3EKKikJUoH1764jVEdKzLdslQCpqdcdbYA8lhfKrGCgK1lrjy26ev7bNx0MkqaX0Hv69f6aOzwlTJZUlOFOKKioepxr9XaPRLioTlHqSEvpzhaCOmRq3b3n8N5K+orzeWouGlNToRWa/Dw2cn7c0apXrWKcGZFQbShgkdAyCTn4ZI1pmmUyTVYSagzW46EuqUUp80dPaI1VqnLiWlbb0eMhKC4jkabT0A6Y0Ko8+jUpswJVdUlxDiudIlKGCVE9s/HV1x9zLXCnVGD77UPtkW2KtUsgSB6U7rcPjM4fduZBp1Wv+JIm5wmDBX5zqj7uVOSNBPfbxH7utMQ2LC21Uhiox3ls1KpKICSgoGOQdTkLz1I7aAXDPYVnpcE/wCYGFPBsrDq8qPN7+p66XH4s3FpxGVLeCZto7utUWaFTHlpg06EluOhsHoerSUlWQB3J017Vo3DpHQV8+FKUnStw79cY9EveqQrs303Io6Z1KLhprb8hpsxyse0lKc5wRjOc9tCaDxEUqryPpJthWUPU5az50FMjzG8+pbVnp/57aU5Ckyq1U/Nq0t2QpRJUp11RJOD3OdaN4C6vUnLTuWnuTVlmHKZdioJ/hrUCFEffgaz3GWGY+mKugfEmJ0EGTHrI/FMzgPie+ZUMQ742zJTJMoMSQnpBOpG069TTBYu5EK7Keieo5OOoPRQ+GozNysBZJXhJPqNBqk1ipphecmYsKPcjpnXiZcFZ5D/AJi51+OllZIITBNMpx8JnSjKu/IEJZCyMpzynm764Fw7u0OitLlPzUoHuB0ErhuSuoQtSam5kdjkao9v1Cdcd0lFcluSUoX7KVq6D8Bqdy1QoFajtVB2/WpYSBvR1p13VLca4Wz5C0Q+fLfP3V+Hu0S6ftba0qImRJojC3F5KlKQCScnVDsKLHjNMFhoJIAwRo00ZINMaJHof1OhCr11t08hgbVMWElEK1Nf/9k=";
var img = new Image();
img.src = document.images[i].src;
var res = FaceDetector.detect(img);
if (res != null) {
var cvs = document.createElement("canvas");
cvs.width = img.width;
cvs.height = img.height;
var ctx = cvs.getContext("2d");
ctx.drawImage(img, 0, 0);
ctx.drawImage(hinata, res.x, res.y, res.w, res.w);
document.images[i].src = cvs.toDataURL();
}
i += 1;
if (i >= max) {
return;
}
var n = arguments.callee;
setTimeout(function() {
n(i, max);
},1);
})(0, document.images.length);
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。