Show Images in Console with Node.js console-png

By  on  

Introducing colors into the command line makes console reading much easier which is why finding Chalk was a life-changing event for me.  I started digging deeper  into making the console more graphical and I found another module that could bring the console to life:  console-png!

The JavaScript

Assuming you've installed console-png or grabbed it from GitHub, it doesn't take much to output an image to the console:

// Attach module to the console
require('console-png').attachTo(console);

// Read the image, let console-png output it to console
console.png(require('fs').readFileSync(__dirname + '/logo.png'));

As for the use case of such a module, there probably aren't a ton.  It would be useful to show a command line splash screen when an app starts up, and it may be useful as a feedback mechanism as the user follows app flow.

Recent Features

  • By
    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn't really made for what we've been using it for.  We've done well to create elegant APIs around XHR but we know we can do better.  Our effort to...

  • By
    Introducing MooTools Templated

    One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating: new Element Madness The first way to create UI-driven...

Incredible Demos

  • By
    CSS Gradients

    With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements.  CSS gradients are another step in that direction.  Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...

  • By
    Create a Photo Stack Effect with Pure CSS Animations or MooTools

    My favorite technological piece of Google Plus is its image upload and display handling.  You can drag the images from your OS right into a browser's DIV element, the images upload right before your eyes, and the albums page displays a sexy photo deck animation...

Discussion

  1. After your article on promises, I’m sad this is using callbacks!

  2. Instead of joining the dirname and filename with string concatenation, you should use the node path joiner so it will work on windows too :)

  3. I like where this is going!

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!