Skip to content

In React Native, implement the functionality to apply brush strokes on an image, generate a mask image containing only the brushing information, and use AI API calls to modify specific areas of the original image.

Notifications You must be signed in to change notification settings

Wangtaofeng/react-native-image-paint-mask

Repository files navigation

Undo Redo Preview Mask Generate Image
undo-redo preview-mask generate

Image Masking and AI Modification Demo

This project is a demo of how to apply brush strokes on an image, generate a mask image with just the brushing information, and use AI API calls to modify specific areas of the original image. The demo is built using Expo, Supabase, fal-ai, and @shopify/react-native-skia.

Features

  • Brush Stroke on Image: Users can draw on an image, and the path of the brush stroke is used to generate a mask image.
  • Undo and Redo: The brush stroke actions can be undone or redone.
  • AI Image Modification: The mask image is combined with an AI API call to modify specific regions of the original image in a natural way.

Setup

  1. Install dependencies:

    bun install
  2. Start the app:

    bunx expo start
  3. The app can be tested on a development build, an Android emulator, an iOS simulator, or in Expo Go.

Key Components

  • app/_layout.ts: This file contains the main implementation for handling brush strokes and generating mask images.

  • components/MaskCanvas: Responsible for rendering the mask image based on the brush strokes applied to the canvas.

  • libs/operatImage: Contains logic for making API calls to modify the image using AI, applying changes based on the generated mask image.

  • libs/storage: Handles the storage of images and generates signed links for the stored images.

Environment Variables

  • Some environment variables are used for AI calls and storing images on a CDN. Ensure you configure the necessary keys and endpoints in your environment.

Resources


You can copy this directly now! Let me know if you'd like to adjust anything.

About

In React Native, implement the functionality to apply brush strokes on an image, generate a mask image containing only the brushing information, and use AI API calls to modify specific areas of the original image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published