npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jp2a

v0.2.0

Published

A node wrapper for the jp2a CLI tool

Downloads

15

Readme

node-jp2a

node-jp2a is a node module for the jp2a CLI tool. jp2a is a small utility that converts JPG images to ASCII. It's written in C and released under the GPL.

Installation

Install with npm:

$ npm install jp2a

node-jp2a requires that the jp2a CLI tool be installed and available on the system's $PATH. The jp2a tool is a popular and widely available utility that should be avaiable in your system's package manager.

For example:

  • on OS X you can install jp2a with Homebrew by running:

    $ brew install jp2a

  • on Ubuntu/Debian you can install jp2a with apt-get:

    $ sudo apt-get install jp2a

Please refer to the jp2a documentation for help installing the tool.

Example

var jp2a = require( "jp2a" );

jp2a( [ "oktocat.jpg", "--width=50", "--background=light" ],  function( output ){
    console.log( output );
});

/*
               ..',,'..
          ,okXNNNNNNNNNNKkl,
       cONNNNNNNNNNNNNNNNNNNNO:
    .dNNNNNNNNNNNNNNNNNNNNNNNNNXo
   cXNNNK;:oONNNNNNNNNNNNOo:;XNNNX:
  xNNNNNc     '.     ..'     oNNNNNo
 dNNNNNNo                    xNNNNNNl
,NNNNNNk                      ONNNNNN.
xNNNNNN.                      .NNNNNNo
0NNNNNX                        NNNNNNk
kNNNNNN.                      ,NNNNNNd
:NNNNNNO                     .0NNNNNN,
 ONNNNNNKc.                .lXNNNNNNk
 .0NNd,l0NNKxo:        cokKNNNNNNNNO
   kNNN:.d0NNK;        lNNNNNNNNNNx
    ;KNNl.. ..         ,NNNNNNNN0,
      ,kNNX00K.        ,NNNNNNx'
         ;d0NN.        ,NN0o,
             .          .
*/

API

jp2a(options, callback(output))

node-jp2a expects two arguments, an options variable and a callback. The options variable can be a simple string containing a path to a local or remote jpg or it can be more complex and can be an array or hash of valid jp2a arguments. The only truly required argument is a file source.

Example with a string options argument and external file source:

jp2a( "http://i1.sndcdn.com/artworks-000007199965-plnzsu-original.jpg", function( output ){
    console.log( output );
});

/*
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKx:. 'OMMMMMMM
MMMMWlldkKNMMMMMMMMMMMMMMMMMMMMMMMMWOo,        ,NMMMMM
MMMW,       .,cok0NMMMMMMMMMMMMXxc.             .KMMMM
MMM;                ;XMMMMMMNl.                   KMMM
MMx                'WMMMMMMMMMO.                  .WMM
MW.                kMMMMKd;.:XMN                   lMM
Mx                 cMMc      .NW.                   NM
M:                  ,k0:      l'                    xM
M;                                                  :M
Mc                                                  ;M
M0                                                  lM
MM,                                                 KM
MMN.                     .lk0k:                    cMM
MMMN,                    KMMMMMd                  'WMM
MMMMMx                   0MMMMMW.                ,WMMM
MMMMMMWo.                'WMMMMM'               dMMMMM
MMMMMMMMMKo'              ;WMMMM.             :XMMMMMM
MMMMMMMMMMMMWKxc,.         'NMMK           .lNMMMMMMMM
MMMMMMMMMMMMMMMMMMMNX0OkxxxxKMM;        .:OWMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMk     .;dKMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMX,;lx0WMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
*/

Example with hash of options:

jp2a( { src:"node.jpg", background:"light", colors: true }, function( output ){
    console.log( output );
});

/*
                                                    ;xN'
                                                  cWMMM'
        ..                 .                 .    xMMMW.        .
     'cx00Oo;.         .;oO0Od:.          'cx00xc.kMMMW.    .:x00Od:.
 .;dO000000000kl'   'ck000000000Oo,   .;dO00000kc.kMMMM..;oO000000000Ol,
OK0000Od:,lk0000KXO000000kl;cx00000KOO00000Od:.   xMMMMKK00000x:,cx0000KXo
KXXXO'      .lNWMMNXXXKc.     .,KNMMWXXXKd'       xMMMMNXXXK,  ... .:NWMMx
KXXXk        ;MMMMNXXXX.        NMMMWXXXXc        dMMMMNXXXK  ,,,,, .MMW0;
KXXXk        ;MMMMNXXXX.        NMMMWXXXXc        dMMMMNXXXK  ..''. .d,
KXXXO        ;MMMMNXXXXKx:.  ;xNMMMMWXXXXXkc.  .l0MMMMMNXXXXKx;.
,o0XO        ;MWOl,lOXXXXXXKWMMMMMXd;ckXXXXXX0NMMMMMWOl,lOXXXXXX'
   .,        .,      .;o0XXNMMNkc.      ,lOXXXMMMKo,      .;o0XX'
                         .:dl'             .;od;.             .:.
*/

Advanced node-jp2a allows you to pipe file data directly into jp2a's STDIN rather than supply jp2a with a file path. This is useful in applications where you are generating or manipulating jpgs on the fly and do not want to save an image to the file system. To do this, set the data attribute in the options hash. It should be noted that data takes priority over src.

Example using STDIN:

/* Use https://github.com/rsms/node-imagemagick to convert a png to a jpg. */
var im = require( "imagemagick" );

im.resize( {
    srcData: fs.readFileSync( "raspberrypi.png", "binary" ),
    width: 1000
}, function( err,stdout ){
    jp2a( { data: stdout, background: "light", width: 50, colors: true }, function( out ){
        console.log( out )
    });
});

/*
         :oX0XNkk:'           .,dx0W0X0c'
  .coKNWMNNKXKXNWWWkl.    ;dKWMXWKNKNNWMNNkl;
  OMXkdcllcccccclod0XMd .XW0OlocccccccollkOWM'
  KMKlcccloocccccccccOM0WNoccccccccloolcccxWM;
  cMWxccccclxkOdlcccccKMMocccccokOkdccccclKMN
   OMNoccccccclxKKklclXMMxccdOKOocccccccckMM'
    kMNxccccccccco0WXWMMMMNNNxcccccccccl0MW,
     ,NMXklcccccccxWMMMMMMMMKlcccccccdOWMx
       '0MNX0xkOKNMMMWNNNWMMMMX0OxkKNWNo.
       lXMNX0000WMXOxxxxxxxOXMN000KXWM0;
     .XMXkxxxxONMKxxxxxxxxxxx0MXkxxxxONM0
    .WM0xxxxONMMMMKOkxxxxxxk0WMMMXOxxxxXMK
    oMNxxOKWMNX000KNMWWWWWMX0OOO0XWW0kxkMM'
   'KMWNWMMXkxxxxxxxkXMMMWkxxxxxxxx0WMNXMM0,
 .0MW00WMMOxxxxxxxxxxxWMMOxxxxxxxxxxkWMNk0NMK.
'WM0xxxXMKxxxxxxxxxxxxNMMOxxxxxxxxxxx0M0xxx0MW.
KMKxxxxXMKxxxxxxxxxxxOMMMNxxxxxxxxxxxOMKxxxxXMO
WM0xxxxWMWkxxxxxxxxx0MMMMMWOxxxxxxxxkNMWxxxxKMK
xMNxxx0MMMMXOkxxkOKWWXKKKXNMWKOOkO0XMMMM0xxkWMc
 OMNO0MMMMMMMMMMMMKkxxxxxxxx0WMMMMMMWXKXNK0WMo
  dMMMKxxxOKWMMMMOxxxxxxxxxxxkWMMMXOxxxxxWMMc
   XMWxxxxxxx0WMWxxxxxxxxxxxxxXMWOxxxxxxxKMX
   'MMkxxxxxxxkWMOxxxxxxxxxxxkWWkxxxxxxxxNMx
    xMWkxxxxxxxOMMKkxxxxxxxkKWMOxxxxxxxxKMN.
     lWMKkxxxxxkMMMMWXKKKXNMMMMOxxxxxx0WMO.
      .oXMWXKKXWMMWXK000000KXWMWXKKXNMWx'
         .:OMMMMM0xxxxxxxxxxxxWMMMWO:.
             ,o0WWKkxxxxxxxkKWM0o'
                .lKMWNXXXNWMXd.
                   .o0NWWKd'
*/

License

GPL