All Projects → JimmyDaddy → React Native Image Marker

JimmyDaddy / React Native Image Marker

Add text or icon watermark to your images

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Image Marker

Mybox
Easy tools of document, image, file, network, location, color, and media.
Stars: ✭ 45 (-73.53%)
Mutual labels:  image, text
Imageselector
图片选择器, 支持多图选择和图片预览
Stars: ✭ 62 (-63.53%)
Mutual labels:  image, photo
Imageviewer.swift
An easy to use Image Viewer that is inspired by Facebook
Stars: ✭ 1,071 (+530%)
Mutual labels:  image, photo
Flutter image cropper
A Flutter plugin for Android and iOS supports cropping images
Stars: ✭ 723 (+325.29%)
Mutual labels:  image, photo
Ucrop
Image Cropping Library for Android
Stars: ✭ 11,003 (+6372.35%)
Mutual labels:  image, photo
Photobrowser
Elegant photo browser in Swift. 图片与视频浏览器。
Stars: ✭ 975 (+473.53%)
Mutual labels:  image, photo
Image
PHP Image Manipulation
Stars: ✭ 12,298 (+7134.12%)
Mutual labels:  image, watermark
Resizer
An image resizing library for Android
Stars: ✭ 406 (+138.82%)
Mutual labels:  image, photo
Vscam
Photography, Communication & Share - Minimalist picture sharing app.
Stars: ✭ 105 (-38.24%)
Mutual labels:  image, photo
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+720%)
Mutual labels:  image, watermark
Lgphotobrowser
照片浏览器,相册选择器,自定义照相机(支持单拍、连拍)
Stars: ✭ 527 (+210%)
Mutual labels:  image, photo
Mergi
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
Stars: ✭ 127 (-25.29%)
Mutual labels:  image, watermark
Easywatermark
🔒 🖼 Securely, easily add a watermark to your sensitive photos. 安全、简单地为你的敏感照片添加水印,防止被小人泄露、利用
Stars: ✭ 519 (+205.29%)
Mutual labels:  image, watermark
Color.js
Extract colors from an image (0.75 KB) 🎨
Stars: ✭ 42 (-75.29%)
Mutual labels:  image, photo
Zmjimageeditor
ZMJImageEditor is a picture editing component like WeChat. It is powerful and easy to integrate, supporting rendering, text, rotation, tailoring, mapping and other functions. (ZMJImageEditor 是一个和微信一样图片编辑的组件,功能强大,极易集成,支持绘制、文字、旋转、剪裁、贴图等功能)
Stars: ✭ 470 (+176.47%)
Mutual labels:  image, text
Mrthumb
【拇指先生】 a simple easy video thumbnail provider,顺滑的获取视频缩略图,支持本地和网络视频,有问题大胆提Issues
Stars: ✭ 60 (-64.71%)
Mutual labels:  image, photo
Ptshowcaseviewcontroller
An initial implementation of a "showcase" view( controller) for iOS apps... Visualizes images, videos and PDF files beautifully! (by @pittleorg) [meta: image, photo, video, document, pdf, album, gallery, showcase, gallery, iOS, iPhone, iPad, component, library, viewer]
Stars: ✭ 395 (+132.35%)
Mutual labels:  image, photo
Tui.image Editor
🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.
Stars: ✭ 4,761 (+2700.59%)
Mutual labels:  image, photo
Automator
Various Automator and AppleScript workflow and scripts for simplifying life
Stars: ✭ 68 (-60%)
Mutual labels:  photo, text
Stfalconimageviewer
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures
Stars: ✭ 1,734 (+920%)
Mutual labels:  image, photo

react-native-image-marker npm version PRs Welcome

Add text or icon watermark to your images

sample

 
 

Installation

RN version < 0.60.0 please use v0.5.2 or older

  • npm install react-native-image-marker --save
  • react-native link

iOS Pod Install

You can use pod instead of link. Add following lines in your Podfile:

pod 'RNImageMarker', :path => '../node_modules/react-native-image-marker'

API

name parameter return decription
markText TextMarkOption Promise<String> mark image with text
markImage ImageMarkOption Promise<String> mark image with icon
  • TextMarkOption
name description
src image url
text the text you want to mark with
position text position(topLeft,topRight,topCenter, center, bottomLeft, bottomCenter, bottomRight)
X distance from the left, if you have set position yet you don't need to set this property again
Y distance from the top, if you have set position you don't need to set this property again
color text color
fontName fontName
fontSize fontSize
shadowStyle text's shadow style: iOS's NSShadowAttributeName, Android's textPaint.shadowLayerStyle
scale scale image
quality image qulaity
filename set filename for the result
saveFormat png jpg base64
textBackgroundStyle text background style
maxSize default value is 2048, need RN version >= 0.60.0, fresco MaxBitmapSize ImagePipelineConfig.Builder.experiment().setMaxBitmapSize(), see #49
export enum ImageFormat {
  png = 'png',
  jpg = 'jpg',
  base64 = 'base64', // base64 string
}

export type TextMarkOption = {
  // image src, local image
  src: ImageSourcePropType,
  text: string,
  // if you set position you don't need to set X and Y
  X?: number,
  Y?: number,
  // eg. '#aacc22'
  color: string,
  fontName: string,
  fontSize: number,
  // scale image
  scale: number,
  // image quality
  quality: number,
  position?: Position,
  filename?: string,
  shadowStyle: ShadowLayerStyle,
  textBackgroundStyle: TextBackgroundStyle,
  saveFormat?: ImageFormat,
  maxSize?: number, // android only see #49 #42
}
  • ImageMarkOption
name description
src image url
markerSrc the icon you want to mark with
position text position(topLeft,topRight,topCenter, center, bottomLeft, bottomCenter, bottomRight)
X distance from the left, if you have set position yet you don't need to set this property again
Y distance from the top, if you have set position you don't need to set this property again
markerScale scale icon
scale scale image
quality image qulaity
filename set filename for the result
saveFormat png jpg base64, default is jpg
maxSize default value is 2048, need RN version >= 0.60.0, fresco MaxBitmapSize ImagePipelineConfig.Builder.experiment().setMaxBitmapSize(), see #49
export type ImageMarkOption = {
  // image src, local image
  src: ImageSourcePropType,
  markerSrc: ImageSourcePropType,
  X?: number,
  Y?: number,
  // marker scale
  markerScale: number,
  // image scale
  scale: number,
  quality: number,
  position?: Position,
  filename?: string,
  saveFormat?: ImageFormat,
  maxSize?: number, // android only see #49 #42
}
  • ShadowStyle
name description
radius blur radius
dx x offset
dy y offset
color shadow color
export type ShadowLayerStyle = {
  'dx': number,
  'dy': number,
  'radius': number,
  'color': string
}
  • textBackgroundStyle

thanks @onka13 for #38

name description
paddingX padding X
paddingY padding y
type default is fit the text, stretchX stretch to fill width, stretchY stretch to fill height
color bg color
export enum TextBackgroundType {
  stretchX = 'stretchX',
  stretchY = 'stretchY'
}

Usage

import ImageMarker from "react-native-image-marker"

···
// add text watermark to a photo

 this.setState({
    loading: true
 })
 Marker.markText({
    src: img.uri,
    text: 'text marker', 
    X: 30,
    Y: 30, 
    color: '#FF0000',
    fontName: 'Arial-BoldItalicMT',
    fontSize: 44,
    shadowStyle: {
        dx: 10.5,
        dy: 20.8,
        radius: 20.9,
        color: '#ff00ff'
    },
    textBackgroundStyle: {
        type: 'stretchX',
        paddingX: 10,
        paddingY: 10,
        color: '#0f0'
    },
    scale: 1, 
    quality: 100
 }).then((res) => {
     this.setState({
        loading: false,
        markResult: res
     })
    console.log("the path is"+res)
 }).catch((err) => {
    console.log(err)
    this.setState({
        loading: false,
        err
    })
 })

···
this.setState({
    loading: true
})
Marker.markText({
    src: img.uri,
    text: 'text marker', 
    position: 'topLeft', 
    color: '#FF0000',
    fontName: 'Arial-BoldItalicMT', 
    fontSize: 44, 
    scale: 1, 
    quality: 100
}).then((res) => {
    console.log("the path is"+res)
    this.setState({
        loading: false,
        markResult: res
    })
}).catch((err) => {
    console.log(err)
    this.setState({
        loading: false,
        err
    })
})

// add icon watermark to a photo

const iconUri = icon.uri
const backGroundUri = img.uri
this.setState({
    loading: true
})

Marker.markImage({
    src: backGroundUri, 
    markerSrc: iconUri, // icon uri
    X: 100, // left
    Y: 150, // top
    scale: 1, // scale of bg
    markerScale: 0.5, // scale of icon
    quality: 100, // quality of image
    saveFormat: 'png', 
}).then((path) => {
    this.setState({
        uri: Platform.OS === 'android' ? 'file://' + path : path,
        loading: false
    })
}).catch((err) => {
    console.log(err, 'err')
    this.setState({
        loading: false,
        err
    })
})

Marker.markImage({
    src: backGroundUri, 
    markerSrc: iconUri, 
    position: 'topLeft',  // topLeft, topCenter,topRight, bottomLeft, bottomCenter , bottomRight, center
    scale: 1, 
    markerScale: 0.5, 
    quality: 100
}).then((path) => {
    this.setState({
        uri: Platform.OS === 'android' ? 'file://' + path : path,
        loading: false
    })
}).catch((err) => {
    console.log(err, 'err')
     this.setState({
        loading: false,
        err
    })
})

// you can also add watermark to a photo with static images
Marker.markImage({
    src: backGroundUri, 
    markerSrc: require('./icon.png'), 
    position: 'topLeft',  // topLeft, topCenter,topRight, bottomLeft, bottomCenter , bottomRight, center
    scale: 1, 
    markerScale: 0.5, 
    quality: 100
}).then((path) => {
    this.setState({
        uri: Platform.OS === 'android' ? 'file://' + path : path,
        loading: false
    })
}).catch((err) => {
    console.log(err, 'err')
     this.setState({
        loading: false,
        err
    })
})
// or base64
Marker.markImage({
    src: { uri: `data:img/jpg;base64,/9j/4qqqAQSkZJRgABAQEBLAEsAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAHnAooDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgddddcI` }, 
    markerSrc: { uri: `data:img/jpg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCAHnAooDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcI` }, 
    position: 'topLeft',  // topLeft, topCenter,topRight, bottomLeft, bottomCenter , bottomRight, center
    scale: 1, 
    markerScale: 0.5, 
    quality: 100
}).then((path) => {
    this.setState({
        uri: Platform.OS === 'android' ? 'file://' + path : path,
        loading: false
    })
}).catch((err) => {
    console.log(err, 'err')
     this.setState({
        loading: false,
        err
    })
})

Extra about Android decoding image

This library use Fresco to decode image on Android. You can set your configuration through Configure Fresco in React Native

  • RN version < 0.60.0 use fresco v1.10.0
  • RN version >= 0.60.0 use fresco v2.0.0 +

see

Save image to file

  • If you want to save the new image result to the phone camera roll, just use the CameraRoll-module from react-native.
  • If you want to save it to an arbitrary file path, use something like react-native-fs.
  • For any more advanced needs, you can write your own (or find another) native module that would solve your use-case.

Contributors

@filipef101 @mikaello @Peretz30 @gaoxiaosong @onka13 @OrangeFlavoredColdCoffee

Example

example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].