Nitro module package
npm install react-native-nitro-paletteA fast and efficient color palette extraction library for React Native, powered by C++ and the MMCQ (Modified Median Cut Quantization) algorithm.
- 🚀 High-performance color extraction using native C++
- 🎨 Extracts dominant colors from images
- 🔧 Configurable color count and quality settings
``sh`
npm install react-native-nitro-palette react-native-nitro-modules react-native-skiaor
yarn add react-native-nitro-palette react-native-nitro-modules react-native-skia
#### For Expo projects
`sh`
yarn expo prebuild --clean
#### For React Native projects
`sh`
cd ios && pod install
`typescript
import { getPaletteAsync } from 'react-native-nitro-palette';
// Extract colors from a remote URL
const colors1 = await getPaletteAsync(
'https://example.jpg',
5, // number of colors to extract (default: 5)
10, // quality (1 = best, 10 = fastest, default: 10)
true // ignore white colors (default: true)
);
// Extract colors from a JS Bundle
const colors2 = await getPaletteAsync(
require('./assets/logo.jpg'),
5,
10,
true
)
// Extract colors from a local image uri
const colors3 = await getPaletteAsync(
'file://...',
5,
10,
true
)
console.log(colors1); // ['rgb(255,0,0)', 'rgb(0,255,0)', ...]
`
Extract colors from an image source.
#### Parameters
- source (string) - The image source (local file path, remote URL, or base64 data)colorCount
- (number) - Optional. Number of colors to extract (default: 5)quality
- (number) - Optional. Quality of color extraction (1 = best, 10 = fastest, default: 10)ignoreWhite
- (boolean) - Optional. Whether to ignore white colors (default: true)
#### Returns
- Promise
MIT
This library is a C++ port of ColorThiefSwift, which is a Swift implementation of ColorThief. The MMCQ (Modified Median Cut Quantization) algorithm implementation is based on the original work.