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

png-to-lcd

v1.1.0

Published

convert png image data into an lcd compatible framebuffer

Downloads

50

Readme

'npm version' 'downloads over month'

png-to-lcd

Convert a PNG image into an LCD/OLED compatible framebuffer

Install

npm install png-to-lcd

What does it do?

png-to-lcd consumes a PNG image file, and returns the image data, formatted for OLED screens (an 8-bit/byte framebuffer). It's just monochrome support for now. It only supports SSD1306 OLED displays. You can buy these pretty cheaply on Adafruit (my favourite), Sparkfun, eBay, and sites like Banggood.

What doesn't it do?

Image prep - the image you pass in should be an RGBA PNG (both colour and greytone are acceptable), and sized to the exact dimensions of the screen you'd like to use. So if your screen is 128x64 pixels, size it so in your image editor of choice.

I suggest Pixelmator, Acorn, or GIMP if you're into desktop software. Alternatively, if you're into super awesome software made in the browser by a badass, try Jenn Schiffer's noice make8bitart.com, which is really quite suitable for this kind of low res screen design.

Usage

png-to-lcd takes three arguments:

string filename - this is pretty obvious really.

bool dither - do you want to run a dithering algorithm on your image?

function callback - callback when image formatting complete

Example

var pngtolcd = require('png-to-lcd');

pngtolcd('cat.png', true, function(err, buffer) {
	console.log(buffer.toString('hex'));
});

What the heck is dithering?

Dithering is a method of diffusing pixels in order to avoid harsh edges or banding where the colours in an image contrast with each other. Fancy algorithms and stuff.

png-to-lcd uses the Floyd Steinberg algorithm specifically, as it produces the clearest images on a pixel screen in my experience.

When should I opt to use dithering?

If you're trying to convert a photo, or detailed image - use dithering! You'll retain more detail.

When should I not ask for dithering?

If you have crisp line detailing in your image, it's best not to dither as it makes a real mess of things. This includes things like text, and simple pixel art drawings. When you pass in false for the dither argument, png-to-lcd will just apply a simple threshold filter to produce your dark/light filters in the buffer.

Show me some output

Ok. You can make stuff like this.

Dithered 128 x 32 display example:
cat 128x32

Dithered 128 x 64 display example:
cat 128x32

Non dithered 128 x 32 display text example:
noopkat

My images don't look perfect (╯°□°)╯︵ ┻━┻

That's understandable. A computer program will do its best to guess at the best optimizations, but it has little context for what the heck it's working on for you. You may find that some screen designs needs a little tweaking before it's perfect.

For non dithered pics - try nudging the pixels using just black and white only (no grey) in your image editor for best results before running it through this module.