typescriptreact-nativeexpobackground-colorreact-color

Is there any working solution for getting average color of an url image in react-native expo?


I just want to get average color of an image and paint my background with that color. But because of I'm using expo in react native I can not find any solution for this.

What should I do to tackle this?


Solution

  • It looks like no way to achieve that using expo, you have one of these option ethers drop expo and move to react native or use your backend to get the average color.

    If You're using React-Native can get the base64 from the image and use react-native-image-colors to get the average color from it like this example:

    const result = await ImageColors.getColors(uri, {
      fallback: '#228B22',
      cache: true,
      key: 'unique_key',
    })
    

    you can check the full documentation on github from here.