Giter VIP home page Giter VIP logo

instagram_js_filter's Introduction

About

Instagram JS Filter is a JS libary for realising Instagram Filters on the web.

Instagram-Like Image Processing Web API

Demo

http://kenju.github.io/instagram_js_filter

Tech-background

As for image-processing, canvas is used for generating filtered images. RGB + alpha valus of each pixels of an image is converted for the targeted effects.

Such image-processing requires high memory-usage and could block user-experience, therefore Web Worker API is used for realising multi-thread processing in the client side.

Install

NPM

$ npm install instagram_js_filter

Bower

$ bower install instagram_js_filter

Or Manually Download

Downloads zipped files from the Github repository.

Documents

A. Server-side

const filter = require('instagram_js_filter');

const imagePath = path.join(__dirname + '/../demo/img/sample.jpg');
fs.readFile(imagePath, (err, imageBuffer) => {
    if (err) {
        reject(err);
    }
    const options = {};
    const base64 = app.filter(imageBuffer, 'horizontalflip', options);
    console.log(base64);
});

Methods

filter(Buffer, effects, [options])

The following table describes the properties of the options object.

Property Type Default Description
out String 'base64' An output of filter().
out

Supported values:

  • 'base64'
  • 'jpg'
  • 'jpeg'
  • 'png'
  • 'gif'

B. Client-side

Downloads JS files

What you need is these files in js directory in the GitHub reposizoty.

  • filter.js - main script file
  • filter.canvas.js - e.g. creates canvas
    • worker.filter.js - supplies all effects
    • worker.js - convert rgb values in background thread
    • worker.util.js - e.g. converts between rgb and hsl
    • lagrange.js - calculate rgb based on lagrange's interpolating function for achieving instagram filter effects

Then, import below 2 scripts. Therefore, all scripts file should be in the same diretory (unless you overwrite raw codes);

<script src="js/filter.js"></script>
<script src="js/filter.canvas.js"></script>

Finally, add data-effect="?" attributes to <img> tags which you want to apply the filters.

<img data-effect="lark" src="img/sample.jpg" alt="">

Supported Effects

  • Instagram filters
    • lark
    • reyes
    • juno
    • slumber
    • crema
    • ludwig
    • aden
    • perpetua
    • amaro
    • mayfair
    • rise
    • hudson
    • valencia
    • xpro2
    • sierra
    • willow
    • lofi
    • earlybird
    • brannan
    • inkwell
    • hefe
    • nashville
    • sutro
    • toaster
    • walden
    • nineteenSeventySeven
    • kelvin
  • Basic filters
    • grayscale
    • sepia
    • luminance
    • brighten
    • darken
    • opacity
    • negaposi
    • brightnessContrast
    • huerotate
    • saturate
    • horizontalFlip
    • verticalFlip
    • doubleFlip
    • horizontalMirror
    • verticalMirror
    • XYMirror

License

Created by and copyright Kenju Wagatsuma Released under the MIT license.

instagram_js_filter's People

Contributors

kenju avatar

Watchers

 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.