User:Penguin-Pal/wikia.js/img2table.js

/*	@author Penguin-Pal replaces image on its URL with a HTML table very good for people who don't know what to do with themselves or are really into eating more than 3.14 pies an hour. easily reches the stack limits as it's javascript and it was meant to do malicious things in websites where you watch movies, rather than helping the world, so it would only work with small images

to import:

(function {		var s = document.createElement("script");		s.type = "text/javascript";		s.src = "http://clubpenguin.wikia.com/wiki/User:Penguin-Pal/wikia.js/img2table.js?action=raw&ctype=text/javascript";	});

also, only apply on raster graphics. conclusion: download reductionizer unless, again, you're too lazy and that's what brought you here to another note, it doesn't work well with partial-transparent parts. so if you have an image of a walrus with pixie dust, you might feel a bit :(

(function {	var img = new Image,		src = location.href;	img.src = src;	img.onload = function {		var dimensions = [this.width, this.height],			a = document.createElement("canvas"),			ctx = a.getContext("2d");		a.width = dimensions[0];		a.height = dimensions[1];		ctx.drawImage(this, 0, 0);		var data = ctx.getImageData(0, 0, dimensions[0], dimensions[1]),			map = ctx.getImageData(0, 0, dimensions[0], dimensions[1]),			table = ,			arr = Array.apply([], new Uint8ClampedArray(map.data));		while (arr.length > 0) {			table += arr.length / 4 % dimensions[0] == 0 ? '\n\t\t \n\t\t ' : ;			var i = arr.splice(0,4);			table += '\n\t\t\t ';		}		document.head.appendChild((function(c) {			c.type = "text/css";			c.innerHTML = "td {\n\twidth: 1px;\n\theight: 1px;\tpadding: 0;\n}";			return c;		}(document.createElement("style")))); document.body.innerHTML = ' ';	} });