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

react-native-color-matrix-image-filters

v7.0.1

Published

Various color matrix based image filters for iOS & Android

Downloads

103,766

Readme

react-native-color-matrix-image-filters

npm version build publish Type Coverage Libraries.io dependency status for latest release npm

Various color matrix based image filters for iOS & Android.

Status

  • iOS & Android:
  • react-native:
    • supported versions: ">=0.60.0"
    • supports both "old" and "new" architecture

Getting started

1. Install latest version from npm

npm i react-native-color-matrix-image-filters

2. Install pods

if using "old" architecture:

npx pod-install

if using "new" architecture:

RCT_NEW_ARCH_ENABLED=1 npx pod-install

Scope

This module is meant to be used for simple stuff, like "grayscaling inactive user avatar" etc. Check react-native-image-filter-kit if you need some advanced features like image blending/composing, extracting filtering results to file system and ability to create custom filters.

Example

import { Image } from 'react-native'
import {
  Grayscale,
  Sepia,
  Tint,
  ColorMatrix,
  concatColorMatrices,
  invert,
  contrast,
  saturate
} from 'react-native-color-matrix-image-filters'

const GrayscaledImage = (imageProps) => (
  <Grayscale>
    <Image {...imageProps} />
  </Grayscale>
)

const CombinedFiltersImage = (imageProps) => (
  <ColorMatrix matrix={concatColorMatrices(sepia(), tint(1.25))}>
    <Image {...imageProps} />
  </ColorMatrix>
)

const ColorMatrixImage = (imageProps) => (
  <ColorMatrix matrix={concatColorMatrices(saturate(-0.9), contrast(5.2), invert())}>
    <Image {...imageProps} />
  </ColorMatrix>
)

| Original | Grayscaled | | :----------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | | | |

| CombinedFilters | ColorMatrix | | :------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------: | | | |

Usage

Each filter support all of View props. Also some filters have optional amount prop which takes a number. ColorMatrix filter has matrix prop which takes a Matrix - an array of 20 numbers. Additionally library exports functions like grayscale, tint etc. - these functions return values of Matrix type and their results can be combined with concatColorMatrices function.

Reference

Supported filters

| Component | Additional props | function | | ---------------- | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | ColorMatrix | matrix: Matrix | - | | Normal | - | normal(): Matrix | | RGBA | red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1 | rgba(red: number = 1, green: number = 1, blue: number = 1, alpha: number = 1): Matrix | | Saturate | amount: number = 1 | saturate(amount: number = 1): Matrix | | HueRotate | amount: number = 0 | hueRotate(amount: number = 0): Matrix | | LuminanceToAlpha | - | luminanceToAlpha(): Matrix | | Invert | - | invert(): Matrix | | Grayscale | amount: number = 1 | grayscale(amount: number = 1): Matrix | | Sepia | amount: number = 1 | sepia(amount: number = 1): Matrix | | Nightvision | - | nightvision(): Matrix | | Warm | - | warm(): Matrix | | Cool | - | cool(): Matrix | | Brightness | amount: number = 1 | brightness(amount: number = 1): Matrix | | Contrast | amount: number = 1 | contrast(amount: number = 1): Matrix | | Temperature | amount: number = 1 | temperature(amount: number = 1): Matrix | | Tint | amount: number = 0 | tint(amount: number = 0): Matrix | | Threshold | amount: number = 0 | threshold(amount: number = 0): Matrix | | Technicolor | - | technicolor(): Matrix | | Polaroid | - | polaroid(): Matrix | | ToBGR | - | toBGR(): Matrix | | Kodachrome | - | kodachrome(): Matrix | | Browni | - | browni(): Matrix | | Vintage | - | vintage(): Matrix | | Night | amount: number = 0.1 | night(amount: number = 0.1): Matrix | | Predator | amount: number = 1 | predator(amount: number = 1): Matrix | | Lsd | - | lsd(): Matrix | | ColorTone | desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000" | colorTone(desaturation: number = 0.2, toned: number = 0.15, lightColor: string = "#FFE580", darkColor: string = "#338000"): Matrix | | DuoTone | firstColor: string = "#FFE580", secondColor: string = "#338000" | duoTone(firstColor: string = "#FFE580", secondColor: string = "#338000"): Matrix | | Protanomaly | - | protanomaly(): Matrix | | Deuteranomaly | - | deuteranomaly(): Matrix | | Tritanomaly | - | tritanomaly(): Matrix | | Protanopia | - | protanopia(): Matrix | | Deuteranopia | - | deuteranopia(): Matrix | | Tritanopia | - | tritanopia(): Matrix | | Achromatopsia | - | achromatopsia(): Matrix | | Achromatomaly | - | achromatomaly(): Matrix |

Functions

  • concatColorMatrices(...matrices: Matrix[]): Matrix

Matrix type

  • A 4x5 matrix for color transformations represented by array - consult Android docs for more specific info about it's format

Misc

  • This library was tested only with standard Image component, but in theory it should work with any image that conforms to CMIFImageView protocol or is based on Android ImageView class
  • Installing react-native-fast-image is not required - this module doesn't depend on it

Credits