GithubHelp home page GithubHelp logo

tkpea / pixels.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from silvia-odwyer/pixels.js

0.0 1.0 0.0 38.65 MB

JavaScript image filtering library, containing over 70 image filters

Home Page: https://silvia-odwyer.github.io/pixels.js/

License: Apache License 2.0

JavaScript 100.00%

pixels.js's Introduction

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.

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.

pixels.js's People

Contributors

silvia-odwyer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.