• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript image filtering library, containing over 70 image filters

Pixels.JS

70+ Photo Filters for your Browser & Node Projects

PRs Welcome Open Source Love Documentation Status GitHub last commit GitHub last commit

PixelsJS Header

Pixels.JS is an image filtering library with over 70 photo filters for use in the browser or with Node.JS.

Image filtering comprises vintage filters, solarizers, inverters, and over ninety more. You can explore these in the official web app, which makes use of the library and each of its comprising filters.

Check Out The Official Website

The official home of PixelsJS is now here! https://silvia-odwyer.github.io/pixels.js/

Read The Docs Documentation Status

For complete PixelsJS documentation: https://pixelsjs.readthedocs.io/en/latest/

Importing Pixels.JS

In The Browser

Include the following script tag in your webpage's head tag:

<script src="https://cdn.jsdelivr.net/gh/silvia-odwyer/pixels.js/dist/Pixels.js"></script>

Node.JS

[NOT YET ON NPM; COMING SOON] npm install pixelsjs

PixelsJS In Action

On our website, you can enter your own image and view its filtered versions as well as extra demos, but here's a quick demo:

PixelsJS can transform even this image of a city into a scene from a cyberpunk film!

Using Pixels.JS

Browser

HTML

After you've included a copy of Pixels.JS in your head tag, include an image in your HTML:

<img src="image.PNG" id="img"/> 
Javascript

Then, in your JavaScript:

// Select the image you wish to filter
var img = document.getElementById("img")

// First parameter is the image object, and the second is the filter you wish to apply.
img.onload = function() {
  pixelsJS.filterImg(img, "twenties");      
}

Node.JS

Usage for Node.JS varies slightly to the browser. Whereas in-browser Pixels.JS automatically replaces the image on the webpage with the newly filtered one, in Node, your environment and canvas libraries can differ, so we've kept usage flexible for Node.

This example uses node-canvas and get-image-data, two NPM modules that make canvas rendering easier, however, you can choose whatever libraries you like; this example merely illustrates using Pixels.js in tandem with node-canvas.

const get_image_data = require('get-image-data');
const PixelsJS = require("Pixels.JS");
const Canvas = require('canvas')

var canvas = new Canvas(200, 200),
    ctx = canvas.getContext('2d'),

get_image_data('./image.jpg', function(error, info) {
  var imgData = info.data
  
  let newImgData = PixelsJS.filterImgData(imgData, "solange");
  
  ctx.putImageData(newImgData, 0, 0);
  
})

Step-By-Step Guide

You can quickly get started with Pixels.JS using the sample code above, but if you're new to web development or want a guided tour, just check out the guides below.

Browser

  1. Include the image on the webpage. <img src="path/to/image.PNG">

  2. In your JS, select the image you want to add filters to. var img = document.getElementById("img")

  3. Pass the image into the filter function, and include the name of the filter you want. var filtered_img = Pixels.JS.filterImg(img, "sepia")

The method filters the image and replaces the current image with the filtered one, so there's no need to append the new image to the DOM, as this is already done for you.

Node.JS

Simply get the image data of the image and pass it to the filterImgData function. The output will be the new image data. You can then place this new image data onto your canvas.

Contributing Guidelines

Want to contribute? I'm always delighted to work with other developers, so submit a Pull Request if you'd like to add any cool image filters. :eyes:

  • Identify which category your filter belongs in. Check the JS files found within the lib directory and see where your filter belongs. If it doesn't belong in any, choose one or open an Issue and I'll create a new category.

  • Add your filter function, ensuring it returns filtered image data.

  • Add the name of your filter and its associated method to the filter_dict variable in index.js. Make sure to import the category file where the filtering method belongs.

Featured In

PixelsJS has been featured in some frontend web dev outlets:

PixelsJS has also been showcased in the weekly Web Design Trends newsletter:

Partners

PixelsJS has also inspired some of the filters found in image processing APIs.

Recommended APIs

One such API is ArcadiaJS, which provides an easy-to-use API for applying cool and intriguing effects to images, whose endpoints are clear and reliable.

Building the Project

Firstly, clone this repository:

git clone https://github.com/silvia-odwyer/pixels.js

Next up, install the dependencies:

cd pixels.js
npm install

To build the library for the browser, run:

npm run build:browser

Future Plans

  • This library currently contains 70 image filters, but I'd like to bring this to 100 in the next few weeks or so.
  • Publish on NPM.

More Repositories

1

photon

âš¡ Rust/WebAssembly image processing library
Rust
2,595
star
2

Onyx

A NodeJS Discord bot used by 1000+ servers
JavaScript
67
star
3

gdl

Graphic design library, written in Rust
Rust
46
star
4

lightbox.js

An all-in-one, responsive React lightbox
TypeScript
37
star
5

rustvis

Data visualisation library, written in Rust
Rust
26
star
6

DesignFX

Graphic design app, built with Vue
Vue
22
star
7

xenon

Markdown/Rich Text editor with a decentralized storage system | Built with Vue
Vue
19
star
8

Onyx-Discord-Bot-Website

Official website for the Onyx Discord Bot https://silvia-odwyer.github.io/Onyx-Discord-Bot-Website/
HTML
12
star
9

flashback

A web app for retro image filtering, powered by JS.
JavaScript
11
star
10

inversion

Video processing Android app | CS3300 Workplace Skills Project
Java
7
star
11

beginner-rust-examples

A collection of beginner Rust examples, each focusing on a certain aspect of programming in Rust.
Rust
3
star
12

WinterBot

Festive Discord bot made during a UCC Netsoc Hackathon 😄 👌
JavaScript
3
star
13

Futuris-Strike

A futuristic version of the classic 70s PONG game built using the LibGDX Library
Java
3
star
14

NiN3Bot

A Go-powered Discord bot.
Go
3
star
15

Java-Instant-Messenger

A WIP Instant Messenger implemented using Java Spring, the Java Message Service, and ActiveMQ
Java
3
star
16

netsoc.co

I woulda forked the original, but the repo was empty.
HTML
2
star
17

13372speak

A Kotlin Android app that translates strings to 1337speak
Kotlin
2
star
18

YourZenBot

A basic Discord bot that sends you proverbs when you ask for them.
Python
2
star
19

rust-spell-checker

A Rust-powered command-line spell checker, including a recommendation system for misspelled words
Rust
2
star
20

ionic-medusajs-ecommerce-app

An ecommerce application built with Medusa and Ionic. Supports Android, iOS and available as a PWA
TypeScript
2
star
21

octofeed

A Kotlin Android app that can parse and display a GitHub user's Atom feed
Kotlin
1
star
22

alexa-arithmetic-quiz

An Amazon Alexa quiz that tests your arithmetic skills.
JavaScript
1
star