• This repository has been archived on 06/Feb/2024
  • Stars
    star
    116
  • Rank 295,372 (Top 6 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

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

Repository Details

A Web Component to apply Instagram-like WebGL filters to photos

Web Photo Filter

Web Photo Filter is a web component to apply Instagram-like WebGL filters to photos.

GitHub release Tweet

Table of contents

Introduction

This component has for goal to make Instagram-like filters for photos accessible for the web.

Image modification solutions and fast processing

Others web based filter solutions often use CSS (for example Instagram.css) or Javascript to modify images.

Applying CSS do not modify the underlying image, and only apply a visual layer to it.

Most Javascript based solutions are not always optimized well enough to be used on mobile devices.

I was looking to create an almost instantaneous filter solution, similar to what Instagram leverages in its mobile application.

Supported by major browsers and devices

As of Feburary 2018, Web Photo Filter utilizes WebGL based technology because it is well supported across modern browsers and mobile devices.

In the future, Web Photo Filter may use WebGL 2 when it will be better supported.

In case WebGL would not be supported on a particular platform, and to avoid producing an error, the component will display the original image without modification.

Lightweight, fast boot time, lazy loading, support across the most popular frontend frameworks

This project is a web component built with the amazing Stencil compiler.

Installation

npm install web-photo-filter

React

You can use a React specific wrapper for this component.

Install it as following:

npm install web-photo-filter-react

Consume it in your code:

import {WebPhotoFilter} from 'web-photo-filter-react/dist';

render() {
    return <WebPhotoFilter/>
}

Usage

The Web Photo Filter Component can be use as following:

<web-photo-filter src="assets/img/test.jpg" filter="sepia"></web-photo-filter>

The only required parameter is the img src tag. It also supports images provided as https if the anonymous crossorigin can be use.

Filter

Filter is an optional parameter. Omitting this attribute or specifying a null value will result in no processing within the component. The source image will be displayed unmodified.

The list of available filters is available in class src/types/web-photo-filter-type.ts. Currently: sepia, blue_monotone, violent_tomato, greyscale, desaturate, brightness, saturation, contrast, hue, cookie, vintage, koda, technicolor, polaroid, bgr.

You can provide a unique filter or, a comma separated list of multiple filters.

filter is a string parameter

Example: Sepia

<web-photo-filter src="assets/img/test.jpg" filter="sepia"></web-photo-filter>

Example: Multiple filters

<web-photo-filter src="assets/img/test.jpg" filter="technicolor, saturation(1.6), contrast"></web-photo-filter>

FilterLoad

If you would like to start or process the result after the component did finish is processing, an event will be triggered containing the resulting image (no filter) or canvas. In addition, it contains also an indication telling you if WebGL is supported or not.

<web-photo-filter onFilterLoad={($event) => imageLoaded($event)} src="imgURI" filter="sepia"></web-photo-filter>

The description of the event is available in the interface src/types/web-photo-filter-result.ts

filterLoad emit an event of type WebPhotoFilterResult

Level

Some filters (brightness, saturation, contrast and hue) are variable. To modify their default values, you could use the variable level.

If multiple filter are provided, it applies to all except if a specific level is provided for a filter, such as for example saturation(1.1).

<web-photo-filter src="assets/img/test.jpg" filter="brightness" level="1.2"></web-photo-filter>

level is a number parameter

Credits

This web component would not had been possible without the brilliant article and WebGL core processing code written by Mike Riethmuller ❤️

The sources of nine filters (Brownie, Brightnes, etc.) were adapted from the project WebGLImageFilter by Dominic Szablewski 👍

Limitation

WebGL is well supported by most modern browsers, but there may be some use cases where it is not. In the case that WebGL is not supported, there is a fallback scenario implemented in the component.

iOS (WKWebView)

While testing a couple of years ago, I found out that Web Photo Filter works very well on iPhone 6 and above. It is possible to load all filters on the same page without performance issues.

Android (WebView)

Likewise I discovered that these filters do not work very well on Android 7 and above. Testing for Android was ran on a Samsung Edge (Android 7.1), Nexus 5X and Sony (Android 8.1).

The Android Webview seems to handle canvas less actively and it's iPhone counterpart. Therefore I do not recommend using all filters on the same page, but only integrating a few of them at a time, otherwise you'll see a negative performance impact.

Tutorial

Simon Grimm (@saimon24) published a tutorial "Ionic Image Filter Like Instagram Using WebGL Filters" which displays step by step how to create a Ionic app and include this component easily.

Note: to follow this tutorial, version 2 of the component has to be use.

License

MIT © David Dal Busco

More Repositories

1

stylo

Another kind of rich text editor
TypeScript
719
star
2

tietracker

A simple, open source and free time tracking app ⏱️
TypeScript
134
star
3

web-social-share

A Web Component to share url and text on social networks
HTML
76
star
4

tsdoc-markdown

Generates markdown documentation from TypeScript source code.
TypeScript
37
star
5

daviddalbusco.com

Freelance Web Developer
Svelte
23
star
6

discoverweekly.dev

The playlists made by devs, every Wednesday.
JavaScript
18
star
7

infiniteScroll

How to implement an Infinite Scroll in Ionic and React with or without Hooks
TypeScript
18
star
8

create-ic

A CLI for initializing projects with Juno or directing devs to the Internet Computer docs
TypeScript
15
star
9

rebelscan

A little scanner app made with the web, you rebel scum!
TypeScript
13
star
10

wooof

An application to browse the internet's biggest collection of open source dog pictures.
TypeScript
10
star
11

cycles.watch

Track the cycles consumption of canister smart contracts on the Internet Computer
Svelte
8
star
12

jsf-dogs

Trick JavaServer Faces, load your bean data from the client side
Java
5
star
13

watamato

A Trello look alike board for my flat hunting in Zürich
TypeScript
5
star
14

proposals.network

Browse and submit proposals on the Internet Computer (ICP) 🏛️📊🗳️
Svelte
5
star
15

juno-openai

A demo showcasing the integration of OpenAI with Juno.
Svelte
5
star
16

motoko_to_rust_migration

JavaScript
3
star
17

certifiedcustomassets

Rust
3
star
18

motoko_rust_interop

Create Rust based canister on the fly from Motoko.
JavaScript
3
star
19

icstreaming

https://forum.dfinity.org/t/http-request-streaming-callback-does-not-stream-chunks-anymore/11298
Motoko
3
star
20

manager

Sample repo for my articles about querying canister smart contracts with NodeJS scripts on the Internet Computer
JavaScript
3
star
21

json-to-enum

Map a JSON file to ENUM in Java
Java
2
star
22

ionic-zurich

Slides presented at the Ionic Zurich Meetup
2
star
23

stencilpwa

TypeScript
2
star
24

icdraw

A whiteboard for sketching hand-drawn like diagrams on Web3
TypeScript
2
star
25

icwebworker

JavaScript
2
star
26

ic_assets

JavaScript
2
star
27

firestore-gatsby

Build Gatsby Websites Using Firestore Data (Without Plugin)
JavaScript
2
star
28

webviewer-links

TypeScript
1
star
29

manifest

https://forum.dfinity.org/t/how-d-they-code-the-nns-front-end-to-do-this/11967
JavaScript
1
star
30

agentjswebworker

JavaScript
1
star
31

webviewer-react-sample

Support issue #20402
JavaScript
1
star
32

my-app-reproducibility-sort

JavaScript
1
star
33

debugstorage

Motoko
1
star
34

web-photo-filter-react

React specific wrapper for web-photo-filter
TypeScript
1
star
35

ng-force-e2e

TypeScript
1
star
36

stencilassets

TypeScript
1
star
37

web-photo-filter-demo

A demo for the Web Photo Filter Web Component
TypeScript
1
star
38

delcan

https://forum.dfinity.org/t/cannot-delete-canisters-anymore/11594
JavaScript
1
star
39

webviewer-angular-sample

There may be some degradation of performance. Your server has not been configured to serve .gz. and .br. files with the expected Content-Encoding.
TypeScript
1
star
40

cypress-mock-blob

HTML
1
star
41

angular-store-demo

Angular State Management Without RxJS  -  An Experiment
TypeScript
1
star
42

stencil-svg-foreignobject

TypeScript
1
star
43

dummy-chat2

TypeScript
1
star
44

rxjs-no-subscribe

TypeScript
1
star
45

cordova-plugin-facebook4-lab

A demo application for the cordova-plugin-facebook4
TypeScript
1
star
46

my-app-hash

Svelte
1
star