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

pixel-scale-epx

v0.0.129

Published

EPX / Scale2x / AdvMAME2x / 3x pixel art scaling algorithms (Eric's Pixel Expansion). 2x, 3x, 4x, 6x, 8x. Anti-aliasing. Works on flat RGBA data.

Downloads

40

Readme

pixel-scale-epx

EPX / Scale2x / AdvMAME2x pixel art scaling algorithm (Eric's Pixel Expansion)

Can also do fast [faux] anti-aliasing by applying EPX then downsampling back to the orignal size.

Also includes the 3x version, aka Scale3x / AdvMAME3x.

Scale pixel art 2x, 3x, 4x, 6x, 8x.

var upscale = require('pixel-scale-epx');
var pixelsData = [r,g,b,a,  r,g,b,a, ... ]; //rgba array 0...255
var width = 256, height = 256; //dimensions of original img
var use8BitColors = false; //if true, ignore lower 8 bits of color channels 
var D2x = upscale.upscaleRgba2x(pixelsData,width,height,use8BitColors); //2x bigger
var D3x = upscale.upscaleRgba3x(pixelsData,width,height,use8BitColors); //3x bigger
var D4x = upscale.upscaleRgba4x(pixelsData,width,height,use8BitColors); //4x bigger [applies 2x op twice]
var D6x = upscale.upscaleRgba6x(pixelsData,width,height,use8BitColors); //6x bigger [applies 2x op then 3x op]
var D8x = upscale.upscaleRgba8x(pixelsData,width,height,use8BitColors); //8x bigger [applies 2x op thrice]

//expand 2x + anti-alias -- eg, expand 4x then downsample 2x -- result is 2x bigger than input 
var D2xAA = upscale.expandAndAntiAliasRgba2x(pixelsData,width,height,use8BitColors);

//if you want ONLY anti-alias without any size change:
var DAA1x = upscale.antiAliasRgba2x_inPlace(pixelsData,width,height,use8BitColors); //works IN PLACE -- size of image not affected

//^in-place anti aliasing via applying EPX 2x then downscaling 2x after

//4x anti aliasing also available, but results look virtually identical
var DAA4x = upscale.antiAliasRgba4x_inPlace(pixelsData,width,height,use8BitColors); //works IN PLACE -- size of image not affected

//can also do "blocky" / naive nearest-neighbor upscale
var blocky2x = upscale.upscaleRgba2x_blocky(pixelsData,width,height);
var blocky4x = upscale.upscaleRgba4x_blocky(pixelsData,width,height);
var blocky8x = upscale.upscaleRgba8x_blocky(pixelsData,width,height);

//format of output is same as input [r,g,b,a ...]

original

^ pixel art enlarged 4x with nearest neighbors

4x

^ pixel art enlarged 4x with EPX

aa2x

^ anti-aliasing via EPX - epx2x + 2x scale down [resulting image scaled 4x to show pixels]

Installation

npm i pixel-scale-epx

Example - upscale a PNG file

In this example we load a PNG file, scale it up 8x (internally we apply EPX algorithm 3 times), then save the result.

var fs = require("fs")
var png = require('fast-png');
var readimage = require("readimage")

var upscale = require('pixel-scale-epx');
var filedata = fs.readFileSync("./test-epx.png");

readimage(filedata, function (err, image) {
    var w = image.width;
    var h = image.height;
    var d = image.frames[0].data;

    var d8x = upscale.upscaleRgba8x(d,w,h)

    var fileData8x = png.encode({width: w*8, height: h*8, data: d8x});
    fs.writeFileSync(`./test_out_8x.png`, fileData8x);
});

8x enlarged 8x

See Also

stonks