# @wordpress/vips

> Utils for working with libvips.

Latest version **4.1.0** (published 2026-09-10) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/vips
pnpm add @wordpress/vips
yarn add @wordpress/vips
bun add @wordpress/vips
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2026-09-10 |
| First published | 2026-02-20 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18.12.0 |
| Dependencies | 2 |
| Unpacked size | 142.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11754 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, media, libvips |

## Links

- npm: https://www.npmjs.com/package/@wordpress/vips
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/vips/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/vips

## Dependencies (2)

- [wasm-vips](https://npm.io/package/wasm-vips.md) ^0.0.18
- [@wordpress/worker-threads](https://npm.io/package/@wordpress/worker-threads.md) ^1.15.0

## Recent versions

- 4.1.0 (latest) — 2026-09-10
- 4.0.2-next.v.202609031004.0 (next) — 2026-09-03
- 1.0.1 (wp-7.0) — 2026-06-30
- 4.0.2-next.v.202608281122.0 — 2026-08-28
- 4.0.0 — 2026-08-26
- 3.1.0 — 2026-08-12
- 3.0.0 — 2026-07-29
- 2.4.0 — 2026-07-14
- 2.3.1-next.v.202607070741.0 — 2026-07-07
- 2.3.0 — 2026-07-01
- 2.2.0 — 2026-06-24
- 2.2.1-next.v.202606191442.0 — 2026-06-19
- 2.1.1 — 2026-06-16
- 2.1.0 — 2026-06-04
- 2.0.0 — 2026-05-27
- … 16 more at https://npm.io/package/@wordpress/vips/versions

## README

# `@wordpress/vips`

Helper package to interact with [`wasm-vips`](https://github.com/kleisauke/wasm-vips).

## Installation

Install the module

```bash
npm install @wordpress/vips --save
```

## Requirements

TypeScript consumers require TypeScript 5 or newer.

## API Reference

<!-- START TOKEN(Autogenerated API docs) -->

### cancelOperations

Cancels all ongoing image operations for a given item ID.

The onProgress callbacks check for an IDs existence in this list, killing the process if it's absent.

_Parameters_

-   _id_ `ItemId`: Item ID.

_Returns_

-   boolean Whether any operation was cancelled.

### compressImage

Compresses an existing image using vips.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _options_ `ConvertImageOptions`: Compression options.

_Returns_

-   `Promise< ArrayBuffer | ArrayBufferLike >`: Compressed file data.

### convertImageFormat

Converts an image to a different format using vips.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _inputType_ `string`: Input mime type.
-   _outputType_ `string`: Output mime type.
-   _options_ `ConvertImageOptions`: Conversion options.

### getUltraHdrInfo

Probes a JPEG to determine whether it is an UltraHDR image with an embedded gain map.

Returns dimensions and HDR headroom on success, or `null` if the buffer is not a valid UltraHDR JPEG (no gain map, decode failure, or unsupported format).

_Parameters_

-   _buffer_ `ArrayBuffer`: Image buffer.

_Returns_

-   `Promise< UltraHdrInfo | null >`: UltraHDR info, or null when the buffer is not UltraHDR.

### hasTransparency

Determines whether an image has visible transparency.

Channel presence alone is not enough: PNG encoders often retain an alpha channel even when every pixel is fully opaque, and animated GIFs declare a transparent color index for disposal-method frame compositing without ever rendering a visibly transparent pixel. This check loads the first frame (any transparency there is visible — there is no previous frame to inherit from) and samples the alpha channel for an actually-transparent pixel.

_Parameters_

-   _buffer_ `ArrayBuffer`: Original file object.

_Returns_

-   `Promise< boolean >`: Whether any pixel in the image is partially or fully transparent.

### resizeImage

Resizes an image using vips.

UltraHDR JPEGs are auto-detected and preserved: libvips's `uhdrload*` has higher priority than `jpegload*`, so `newFromBuffer`/`thumbnailBuffer` decode the gain map alongside the base image, and `jpegsave*` delegates to `uhdrsave*` on output when a gain map is attached.

Sub-sizes of animated images are generated from the first frame only, matching WordPress core's server-side behavior: both GD and Imagick flatten animated images when resizing, and `wp_calculate_image_srcset()` prevents flattened sub-sizes and the animated full-size image from mixing in a srcset. Loading all frames (`[n=-1]`) would re-encode a full animated GIF per sub-size, which takes tens of seconds for long animations and can produce sub-sizes larger than the original file. See <https://github.com/WordPress/gutenberg/issues/80266>.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _resize_ `ImageSizeCrop`: Resize options.
-   _options_ `ResizeImageOptions`: Additional resize options.

_Returns_

-   `Promise< { buffer: ArrayBuffer | ArrayBufferLike; width: number; height: number; originalWidth: number; originalHeight: number; } >`: Processed file data plus the old and new dimensions.

### rotateImage

Rotates an image based on EXIF orientation value.

EXIF orientation values: 1 = Normal (no rotation needed) 2 = Flipped horizontally 3 = Rotated 180° 4 = Flipped vertically 5 = Rotated 90° CCW and flipped horizontally 6 = Rotated 90° CW 7 = Rotated 90° CW and flipped horizontally 8 = Rotated 90° CCW

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _orientation_ `number`: EXIF orientation value (1-8).

_Returns_

-   `Promise< { buffer: ArrayBuffer | ArrayBufferLike; width: number; height: number; } >`: Rotated file data plus the new dimensions.

### vipsCancelOperations

Cancels all ongoing image operations for a given item ID.

The onProgress callbacks check for an IDs existence in this list, killing the process if it's absent.

_Parameters_

-   _id_ `ItemId`: Item ID.

_Returns_

-   boolean Whether any operation was cancelled.

### vipsCompressImage

Compresses an existing image using vips.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _options_ `ConvertImageOptions`: Compression options.

_Returns_

-   `Promise< ArrayBuffer | ArrayBufferLike >`: Compressed file data.

### vipsConvertImageFormat

Converts an image to a different format using vips.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _inputType_ `string`: Input mime type.
-   _outputType_ `string`: Output mime type.
-   _options_ `ConvertImageOptions`: Conversion options.

### vipsGetUltraHdrInfo

Probes a JPEG to determine whether it is an UltraHDR image with an embedded gain map.

Returns dimensions and HDR headroom on success, or `null` if the buffer is not a valid UltraHDR JPEG (no gain map, decode failure, or unsupported format).

_Parameters_

-   _buffer_ `ArrayBuffer`: Image buffer.

_Returns_

-   `Promise< UltraHdrInfo | null >`: UltraHDR info, or null when the buffer is not UltraHDR.

### vipsHasTransparency

Determines whether an image has visible transparency.

Channel presence alone is not enough: PNG encoders often retain an alpha channel even when every pixel is fully opaque, and animated GIFs declare a transparent color index for disposal-method frame compositing without ever rendering a visibly transparent pixel. This check loads the first frame (any transparency there is visible — there is no previous frame to inherit from) and samples the alpha channel for an actually-transparent pixel.

_Parameters_

-   _buffer_ `ArrayBuffer`: Original file object.

_Returns_

-   `Promise< boolean >`: Whether any pixel in the image is partially or fully transparent.

### vipsResizeImage

Resizes an image using vips.

UltraHDR JPEGs are auto-detected and preserved: libvips's `uhdrload*` has higher priority than `jpegload*`, so `newFromBuffer`/`thumbnailBuffer` decode the gain map alongside the base image, and `jpegsave*` delegates to `uhdrsave*` on output when a gain map is attached.

Sub-sizes of animated images are generated from the first frame only, matching WordPress core's server-side behavior: both GD and Imagick flatten animated images when resizing, and `wp_calculate_image_srcset()` prevents flattened sub-sizes and the animated full-size image from mixing in a srcset. Loading all frames (`[n=-1]`) would re-encode a full animated GIF per sub-size, which takes tens of seconds for long animations and can produce sub-sizes larger than the original file. See <https://github.com/WordPress/gutenberg/issues/80266>.

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _resize_ `ImageSizeCrop`: Resize options.
-   _options_ `ResizeImageOptions`: Additional resize options.

_Returns_

-   `Promise< { buffer: ArrayBuffer | ArrayBufferLike; width: number; height: number; originalWidth: number; originalHeight: number; } >`: Processed file data plus the old and new dimensions.

### vipsRotateImage

Rotates an image based on EXIF orientation value.

EXIF orientation values: 1 = Normal (no rotation needed) 2 = Flipped horizontally 3 = Rotated 180° 4 = Flipped vertically 5 = Rotated 90° CCW and flipped horizontally 6 = Rotated 90° CW 7 = Rotated 90° CW and flipped horizontally 8 = Rotated 90° CCW

_Parameters_

-   _id_ `ItemId`: Item ID.
-   _buffer_ `ArrayBuffer`: Original file buffer.
-   _type_ `string`: Mime type.
-   _orientation_ `number`: EXIF orientation value (1-8).

_Returns_

-   `Promise< { buffer: ArrayBuffer | ArrayBufferLike; width: number; height: number; } >`: Rotated file data plus the new dimensions.

<!-- END TOKEN(Autogenerated API docs) -->

---
_Source: https://npm.io/package/@wordpress/vips · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
