
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
wasm-image-optimization
Advanced tools
High-performance image conversion and resizing tool leveraging WebAssembly (Emscripten). Built on the Skia rendering engine, it supports animations (GIF/WebP) and modern formats (AVIF/SVG/ThumbHash).
It provides a lightweight, dependency-free solution for generating high-quality visuals and documents across Node.js, Cloudflare Workers, Deno, and Web Browsers.
https://node-libraries.github.io/wasm-image-optimization/
https://github.com/SoraKumo001/wasm-image-optimization-samples
| Format | Input (Decoding) | Output (Encoding) | Notes |
|---|---|---|---|
| PNG | ✅ | ✅ | |
| JPEG | ✅ | ✅ | |
| WebP | ✅ | ✅ | Supports animations |
| AVIF | ✅ | ✅ | Powered by AOM encoder / dav1d decoder |
| ThumbHash | ✅ | ✅ | Returns a compact image placeholder hash |
| RAW | ✅ | ✅ | Returns uncompressed 32-bit RGBA pixel data |
| GIF | ✅ | - | Input only (supports animations) |
| SVG | ✅ | - | High-fidelity rendering via SkSVGDOM |
| BMP | ✅ | - | |
| None | ✅ | ✅ | Returns original data with metadata |
pnpm add wasm-image-optimization
After installation, the wasm-image-optimization command will be available.
# Basic conversion (default is WebP)
wasm-image-optimization input.png
# Specify format and quality
wasm-image-optimization input.jpg -f avif -q 80
# Convert maintaining animation
wasm-image-optimization input.gif -f webp -a
# Specify encoding speed (e.g., for AVIF)
wasm-image-optimization input.png -f avif -s 0
# Resize and save with a different name
wasm-image-optimization input.png -w 800 -h 600 -o resized.webp
import { optimizeImage } from 'wasm-image-optimization';
const inputBuffer = ...; // Uint8Array or ArrayBuffer
const result = await optimizeImage({
image: inputBuffer,
width: 800,
height: 600,
fit: 'contain', // 'contain' | 'cover' | 'fill' (default: 'contain')
format: 'webp', // 'none' | 'png' | 'webp' | 'jpeg' | 'avif' | 'raw' | 'thumbhash'
quality: 85,
speed: 6, // 0-10 (encoding speed for AVIF, etc.)
animation: true // maintain animation if possible
});
OptimizeParams)| Parameter | Type | Default | Description |
|---|---|---|---|
image | Uint8ArrayArrayBuffer | Required | The raw binary data of the image to process. |
width | number | - | Target width for resizing. If omitted, it's calculated from height to maintain aspect ratio. |
height | number | - | Target height for resizing. If omitted, it's calculated from width to maintain aspect ratio. |
fit | contain cover fill | 'contain' | Resizing strategy. - contain: Fits within bounds (aspect ratio preserved). - cover: Fills bounds (may crop). - fill: Stretches to match bounds exactly. |
format | string | 'webp' | Output format: 'none', 'png', 'webp', 'jpeg', 'avif', 'raw', 'thumbhash'. Note: If animation: true and the input is animated, this is forced to 'webp'. |
quality | number | 100 | Compression quality (0-100). Applies to WebP, JPEG, and AVIF. |
speed | number | 6 | Encoding speed (0-10). Primarily used for AVIF. Lower is slower but better compression. |
animation | boolean | false | If true, preserves animation frames (e.g., GIF/animated WebP source). |
OptimizeResult)| Property | Type | Description |
|---|---|---|
data | Uint8Array | The processed image data. |
originalWidth | number | Width of the input image. |
originalHeight | number | Height of the input image. |
originalAnimation | boolean | true if the input image was animated. |
originalFormat | string | Format of the input image (e.g., "jpeg", "gif"). |
width | number | Width of the output image. |
height | number | Height of the output image. |
animation | boolean | true if the output image is animated. |
format | string | Format of the output image. |
You can monitor the internal processing and Skia logs.
import { ImageConverter } from "wasm-image-optimization";
const converter = new ImageConverter();
// Set log level: 0 (None), 1 (Error), 2 (Warning), 3 (Info), 4 (Debug)
converter.logLevel = 3;
// Custom log handler
converter.onLog = (level, message) => {
console.log(`[ImageConverter][${level}] ${message}`);
};
Use Workers for high-throughput processing without blocking the main thread.
import { optimizeImage } from "wasm-image-optimization/workers";
const result = await optimizeImage({
image: inputBuffer,
width: 800,
format: "png",
});
# Install dependencies
pnpm install
# Configure CMake (using Ninja)
pnpm wasm:configure
# Build Wasm
pnpm wasm:build
MIT
FAQs
Optimize images with wasm on edge runtime
The npm package wasm-image-optimization receives a total of 2,543 weekly downloads. As such, wasm-image-optimization popularity was classified as popular.
We found that wasm-image-optimization demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.