百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-photo-manipulator

> 前端框架
开源

React Native 图像处理 API 可为 Android 和 iOS 编程地编辑照片。它支持打印文本、覆盖其他图像(添加水印)、调整大小等功能。

390 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

React Native 图像处理 API 可为 Android 和 iOS 编程地编辑照片。它支持打印文本、覆盖其他图像(添加水印)、调整大小等功能。

React Native Photo Manipulator

React Native Image Processing API to edit photo programmatically for Android and iOS.

demo.webm

Platform Supported

Framework Android iOS
React Native ✔️ ✔️
Expo with development build ✔️ ✔️
Expo Go ❌ ❌

Getting started

For react native 0.60 and above

bash
$ yarn add react-native-photo-manipulator

(or)

bash
$ npm install react-native-photo-manipulator

For react native 0.59 and below

Please read Get Started Guide

For Expo with development build

bash
$ yarn expo install react-native-photo-manipulator

(or)

bash
$ npx expo install react-native-photo-manipulator

Usage

Import library with

javascript
import RNPhotoManipulator from 'react-native-photo-manipulator';

API

  • Methods:

    • crop()
    • optimize()
    • flipImage()
    • rotateImage()
    • overlayImage()
    • printText()
    • batch()
  • Types:

    • ImageSource
    • PhotoBatchOperations
    • PhotoBatchOverlay
    • PhotoBatchPrintText
    • PhotoBatchFlip
    • PhotoBatchRotate
    • FlipMode
    • RotationMode
    • Point
    • Rect
    • Size
    • TextAlign
    • TextDirection
    • TextOptions

Method

Crop and resize

Crop image with cropRegion and resize to targetSize if specified

Signature
typescript
static crop(image: ImageSource, cropRegion: Rect, targetSize?: Size) => Promise
Parameter Type Required Description
image ImageSource Yes The image
cropRegion Rect Yes The region of image to be cropped
targetSize Size No The target size of result image
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const cropRegion = { x: 5, y: 30, height: 400, width: 250 };
const targetSize = { height: 200, width: 150 };

RNPhotoManipulator.crop(image, cropRegion, targetSize).then(path => {
    console.log(`Result image path: ${path}`);
});

Optimize

Save result image with specified quality between 0 - 100 in jpeg format

Signature
typescript
static optimize(image: ImageSource, quality: number) => Promise
Parameter Type Required Description
image ImageSource Yes The image
quality number Yes The quality of result image between 0 - 100
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const quality = 90;

RNPhotoManipulator.optimize(image, 90).then(path => {
    console.log(`Result image path: ${path}`);
});

Flip Image

Flip image horizontally, vertically or both

Signature
typescript
static flipImage(image: ImageSource, mode: FlipMode) => Promise
Parameter Type Required Description
image ImageSource Yes The background image
mode FlipMode Yes Flip mode Horizontal, Vertical or Both
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const mode = FlipMode.Vertical;

RNPhotoManipulator.flipImage(image, mode).then(path => {
    console.log(`Result image path: ${path}`);
});

Rotate Image

Rotate image 90° (90° Clockwise), 180° (Half Rotation) or 270° (90° Counterclockwise)

Signature
typescript
static rotateImage(image: ImageSource, mode: RotationMode) => Promise
Parameter Type Required Description
image ImageSource Yes The background image
mode RotationMode Yes Rotation mode 90° (90° Clockwise), 180° (Half Rotation) or 270° (90° Counterclockwise)
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const mode = RotationMode.R90;

RNPhotoManipulator.rotateImage(image, mode).then(path => {
    console.log(`Result image path: ${path}`);
});

Overlay Image

Overlay image on top of background image

Signature
typescript
static overlayImage(image: ImageSource, overlay: ImageSource, position: Point) => Promise
Parameter Type Required Description
image ImageSource Yes The background image
overlay ImageSource Yes The overlay image
position Point Yes The position of overlay image in background image
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const overlay = "https://www.iconfinder.com/icons/1174949/download/png/128";
const position = { x: 5, y: 20 };

RNPhotoManipulator.overlayImage(image, overlay, position).then(path => {
    console.log(`Result image path: ${path}`);
});

Print Text

Print texts into image

Signature
typescript
static printText(image: ImageSource, texts: TextOptions[]) => Promise
Parameter Type Required Description
image ImageSource Yes The image
texts TextOptions[] Yes The list of text operations
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
javascript
const image = "https://unsplash.com/photos/qw6qQQyYQpo/download?force=true";
const texts = [
    { position: { x: 50, y: 30 }, text: "Text 1", textSize: 30, color: "#000000" },
    { position: { x: 50, y: 30 }, text: "Text 1", textSize: 30, color: "#FFFFFF", thickness: 3 }
];

RNPhotoManipulator.printText(image, texts).then(path => {
    console.log(`Result image path: ${path}`);
});

Batch

Crop, resize and do operations (overlay and printText) on image

Signature
typescript
static batch(image: ImageSource, operations: PhotoBatchOperations[], cropRegion: Rect, targetSize?: Size, quality?: number) => Promise
Parameter Type Required Description
image ImageSource Yes The image
operations PhotoBatchOperations[] Yes The list of operations
cropRegion Rect Yes The region of image to be cropped
targetSize Size No The target size of result image
quality number No The quality of result image between 0 - 100
mimeType 'image/jpeg', 'image/png' No Output file format
Returns

Promise with image path in cache directory

Example
…

Types

ImageSource

Image resource can be url or require()

Type Description
number Image from require('path/to/image')
string Image from url supports (file://, http://, https:// and ftp://) or base64 encoded (data:image/png;base64,iVBORw...)

PhotoBatchOperations

Represent overlay image, print text or flip operation

PhotoBatchOverlay

Overlay image batch operation

| Property | Type | Description

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptimage-manipulationimage-processingreact-native

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架