A React Native library for extracting prominent colors from images (URL, local file, base64, content URI) on iOS, Android, Expo, and web. Current stable version is v2.6.0, released roughly monthly. Wraps native palettes: Android Palette, iOS UIImageColors, web node-vibrant. Key differentiators: unified API across all platforms, built-in caching, and fallback support. Requires React Native 0.70+ and Expo SDK 47+. For older RN versions, use v1.x.
npm install react-native-image-colorsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: fetch colors from a URL and display all six palette properties with caching enabled.
Replace `import ImageColors from 'react-native-image-colors'` with `import { getColors } from 'react-native-image-colors'`.Use `getColors(url, config).then().catch(err => console.warn(err))` or try-catch with async/await.
Remove any `quality` property from the config object.
Always provide a unique `key` string when setting `cache: true`.
Test across platforms; if web results differ, consider platform-specific handling.
Either upgrade React Native to 0.70+ or install react-native-image-colors@1.x.
Provide a fallback color in the config and use optional chaining or nullish coalescing when accessing properties.
Ensure you handle the result state correctly: `setColors(result)` and only render after `colors` is not null.
For Expo: run `npx expo prebuild`. For React Native CLI: ensure native modules are installed and reinstall pods: `cd ios && pod install && cd ..`.
Add a unique `key` string in config, e.g., `{ cache: true, key: url }`.Ensure WebAssembly is allowed or use fallback. See web documentation.
Check platform compatibility; only iOS, Android, and web are supported.