Skip to content
Menu
Auto
English

Installation

React Native Image Marker uses native code on iOS and Android and a Canvas 2D implementation on Web. Install it once; native targets must link and rebuild, while Web runs directly in the browser.

  1. Install the package.

    Terminal window
    npm install react-native-image-marker
  2. Install iOS pods when your project has an iOS target.

    Terminal window
    npx pod-install
  3. Rebuild the native app.

    Terminal window
    npx react-native run-android
    # or
    npx react-native run-ios

Marker.markText renders one or more text layers and resolves with the generated image path.

import Marker, { ImageFormat, Position } from 'react-native-image-marker';
const result = await Marker.markText({
backgroundImage: {
src: require('./images/background.jpg'),
},
watermarkTexts: [
{
text: '© Acme Studio',
position: {
position: Position.bottomRight,
X: 24,
Y: 24,
},
style: {
color: '#FFFFFF',
fontSize: 28,
},
},
],
filename: 'marked-photo',
saveFormat: ImageFormat.jpg,
quality: 92,
});

For image-only or mixed layers, see Choose an API.

On iOS and Android, use the same source shapes you already use in React Native:

  • A bundled asset from require('./image.png')
  • A URI object or remote URI supported by React Native’s image loader
  • A complete data:image/...;base64,... data URL

On Web, use a URL string, { uri }, data URL, Blob, File, or loaded browser image. Remote URLs must permit CORS. Numeric React Native asset IDs must first be resolved to a URL.

Native JPEG and PNG output is written to the platform cache directory. Web output is always a data URL; native ImageFormat.base64 also returns an in-memory data URL.