npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wordpress/vips

v3.1.0

Published

Utils for working with libvips.

Readme

@wordpress/vips

Helper package to interact with wasm-vips.

Installation

Install the module

npm install @wordpress/vips --save

API Reference

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.