@capacitor-community/image-manipulator

中文文档
8.0.0发布于 2026/02/09MITTypeScriptESM + CJS零依赖近 30 天下载 2029

The Image Manipulator plugin is designed to manipulate images (resize, compress, crop etc.)

原始使用文档
文档目录14 节
  1. Image Manipulator Plugin
  2. Table of Contents
  3. Maintainers
  4. About
  5. Plugin versions
  6. Supported Platforms
  7. Install
  8. API
  9. getDimensions(...)
  10. resize(...)
  11. Interfaces
  12. Usage
  13. Resize image
  14. Resize image


Image Manipulator Plugin

@capacitor-community/image-manipulator

Capacitor community plugin to manipulate images (resize, compress, crop etc.)


Table of Contents

Maintainers

MaintainerGitHubActive
ryaaryaayes

About

This capcitor plugin allows reading image dimensions (width and height) and resize images. This plugin is inspired and similar to cordova-plugin-image-resizer plugin. Please note that it does not depend on cordova-plugin-camera plugin and can be used independently.


Features:

  • supports getting image dimensions
  • supports resizing image
  • supports Android and iOS platforms

NOTE: The plugin version 8.0.0 is compatible with Capacitor 8

Plugin versions

Capacitor versionPlugin version
8.x8.x
7.x7.x
6.x6.x

Supported Platforms

  • iOS
  • Android

Install

npm install @capacitor-community/image-manipulator
npx cap sync

API

getDimensions(...)

getDimensions(options: GetDimensionsOptions) => Promise<{ width: number; height: number; }>

Get dimensions of an image (width and height)

ParamTypeDescription
optionsGetDimensionsOptionsoptions to get dimensions of an image

Returns: Promise<{ width: number; height: number; }>

Since: 6.0.0


resize(...)

resize(options: ResizeOptions) => Promise<{ originalWidth: number; originalHeight: number; resizedWidth: number; resizedHeight: number; imagePath: string; webPath: string; resized: boolean; }>

Method to resize an image based on the provided options and return the resized image details. Please note that the resized image will respect the aspect ratio of the original image and will be resized to be equal to less of the provided maxWidth or maxHeight. If the image both width and height are less than the provided maxWidth and maxHeight, the image will not be resized and the original image details will be returned with resized as false. If either maxWidth or maxHeight is not provided or 0, this parameter will be ignored (not used) and the image will be resized based on the provided maxWidth or maxHeight, accordingly. Please note that either maxWidth or maxHeight must be provided to resize an image.

ParamTypeDescription
optionsResizeOptionsOptions to resize an image

Returns: Promise<{ originalWidth: number; originalHeight: number; resizedWidth: number; resizedHeight: number; imagePath: string; webPath: string; resized: boolean; }>

Since: 6.0.0


Interfaces

GetDimensionsOptions

PropTypeDescriptionSince
imagePathstringThe path to the image to get its dimensions.6.0.0

ResizeOptions

PropTypeDescriptionSince
imagePathstringThe path to the image to resize.6.0.0
folderNamestring(Android Only) The name of the folder to store the resized images (optional, defaults to 'ResizedImages' if not provided).6.0.0
fileNamestringThe name of the resized file without extension (optional, timestamp as name if not provided).6.0.0
qualitynumberThe resized image quality from 0 to 100, where 100 is max (optional, defaults to 85 if not provided).6.0.0
maxWidthnumberThe max width of the resized image (optional, but at least either height or width must be provided).6.0.0
maxHeightnumberThe max height of the resized image (optional, but at least either width or height must be provided).6.0.0
fixRotationbooleanFix the rotation of the image based on EXIF metadata (optional, defaults to false if not provided).6.0.0

Usage

Please also see example-app for a complete example.

Resize image

import { ImageManipulator } from '@capacitor-community/image-manipulator';

const options: ImageResizeOptions = {
  imagePath: 'path/to/image.jpg',
  maxWidth: 300,
  maxHeight: 300,
  quality: 85,
  folderName: 'ResizedImages',
  fileName: 'resized',
  fixRotation: true
};
const result = await ImageManipulator.resize(options);

Resize image

import { ImageManipulator } from '@capacitor-community/image-manipulator';

const options: GetDimensionsOptions = {
  imagePath: 'path/to/image.jpg'
};
const result = await ImageManipulator.getDimensions(options);

版本与发布记录

@capacitor-community/image-manipulator 共发布 3 个版本,首次发布于 2025/01/30;过去 12 个月发布了 1 个版本。

版本发布日期距今
8.0.0latest2026/02/098 个月前
7.0.02025/02/031.8 年前
6.0.02025/01/301.8 年前

关于 @capacitor-community/image-manipulator 的常见问题

@capacitor-community/image-manipulator 是什么?

The Image Manipulator plugin is designed to manipulate images (resize, compress, crop etc.)

如何安装 @capacitor-community/image-manipulator?

在项目目录运行 npm install @capacitor-community/image-manipulator,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capacitor-community/image-manipulator 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capacitor-community/image-manipulator 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capacitor-community/image-manipulator 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@capacitor-community/image-manipulator 可以商用吗?

@capacitor-community/image-manipulator 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capacitor-community/image-manipulator 的下载量有多少?

根据 npm 官方下载统计,@capacitor-community/image-manipulator 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,029 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capacitor-community/image-manipulator 还在维护吗?

最新版本 8.0.0 发布于 2026/02/09(8 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/01/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。