Skip to content

Instantly share code, notes, and snippets.

@msfeldstein
Last active April 5, 2017 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msfeldstein/c92f8f5005310275d7ffc60707a19845 to your computer and use it in GitHub Desktop.
Save msfeldstein/c92f8f5005310275d7ffc60707a19845 to your computer and use it in GitHub Desktop.
console.image
/**
* Modified version of something Dubiously created by Adrian Cooney
* http://adriancooney.github.io
* adapted from https://github.com/adriancooney/console.snapshot
*/
(function(console) {
function getBox(width, height) {
return {
string: "+",
style: "font-size: 1px; padding: " + Math.floor(height/2) + "px " + Math.floor(width/2) + "px; line-height: " + height + "px;"
}
}
/**
* Display an image in the console.
* @param {string} url base64 url of image
*/
console.image = function(url, width, height) {
var dim = getBox(width, height);
console.log("%c" + dim.string, dim.style + "background: url(" + url + "); background-size: " + (width) + "px " + (height) + "px; color: transparent;");
};
})(console);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment