# ts-images

> Modern image optimizations & manipulations.

Latest version **0.2.17** (published 2026-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-images
pnpm add ts-images
yarn add ts-images
bun add ts-images
```

Provides the command `imgx`.

## Health

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

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.17 |
| Published | 2026-09-04 |
| First published | 2026-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 7 |
| Unpacked size | 734.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | Chris Breuer <chris@stacksjs.org> |
| Maintainers | chrisbreuer |
| Keywords | image, manipulation, compression, web optimization, jpg, png, avif, webp, sharp, bun, stacks, typescript, javascript, app-icon, xcode, macos, ios |

## Links

- npm: https://www.npmjs.com/package/ts-images
- Repository: https://github.com/stacksjs/ts-images
- Issues: https://github.com/stacksjs/ts-images/issues
- npm.io page: https://npm.io/package/ts-images

## Dependencies (7)

- [ts-gif](https://npm.io/package/ts-gif.md) ^0.1.2
- [ts-jpeg](https://npm.io/package/ts-jpeg.md) ^0.3.1
- [@stacksjs/ts-bmp](https://npm.io/package/@stacksjs/ts-bmp.md) ^0.1.0
- [@stacksjs/ts-png](https://npm.io/package/@stacksjs/ts-png.md) ^0.1.2
- [@stacksjs/ts-svg](https://npm.io/package/@stacksjs/ts-svg.md) ^0.1.1
- [@stacksjs/ts-avif](https://npm.io/package/@stacksjs/ts-avif.md) ^0.1.4
- [@stacksjs/ts-webp](https://npm.io/package/@stacksjs/ts-webp.md) ^0.1.2

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.2.17 (latest) — 2026-09-04
- 0.2.16 — 2026-09-04
- 0.2.15 — 2026-09-04
- 0.2.14 — 2026-09-01
- 0.2.13 — 2026-08-27
- 0.2.12 — 2026-08-18
- 0.2.11 — 2026-08-16
- 0.2.10 — 2026-08-12
- 0.2.9 — 2026-08-12
- 0.2.8 — 2026-08-08
- 0.2.7 — 2026-08-03
- 0.2.6 — 2026-08-02
- 0.2.5 — 2026-07-26
- 0.2.4 — 2026-07-26
- 0.2.3 — 2026-07-26
- … 8 more at https://npm.io/package/ts-images/versions

## README

# ts-images

A powerful image optimization and manipulation toolkit for modern web development. This is the core library package of the imgx project.

## Installation

```bash
bun add ts-images -d
# or
npm install ts-images --save-dev
```

## Usage

### Library

```typescript
import { optimizeImage, processImage } from 'ts-images'

// Optimize a single image
await optimizeImage('input.jpg', {
  quality: 80,
  format: 'webp',
  output: 'output.webp',
})

// Process with advanced options
await processImage('photo.png', {
  resize: { width: 800, height: 600 },
  format: 'avif',
  quality: 75,
})
```

### Activity share cards

Create branded, browser-safe SVG cards for activity feeds, downloads, and native social sharing. The card includes a normalized route trace and the activity's key metrics without embedding source coordinates in the output.

```typescript
import { activityShareCardSvg } from 'ts-images/activity-card'

const svg = activityShareCardSvg({
  activityType: 'Trail run',
  athlete: 'Chris',
  completedAt: 'August 12, 2026',
  distance: '8.42 mi',
  duration: '1:07:32',
  elevation: '1,284 ft',
  pace: '8:01 /mi',
  preset: 'story',
  route: recordedPoints,
  title: 'Headlands sunrise',
})
```

Use `square` for feed posts, `story` for vertical stories, and `landscape` for link previews. `activityShareCardFileName()` creates a safe download name for the selected preset.

### CLI

```bash
# Optimize an image
imgx optimize input.jpg --quality 80 --format webp

# Batch process images
imgx batch ./images --format webp --quality 80

# Generate app icons
imgx app-icon logo.png --output ./icons

# Generate favicons
imgx favicon logo.svg --output ./public

# Optimize SVGs
imgx svg-optimize ./svgs
```

## Features

- **Format Conversion** - Convert between JPEG, PNG, WebP, AVIF, GIF, BMP
- **Image Optimization** - Lossy and lossless compression with smart quality settings
- **Batch Processing** - Process multiple images with configurable pipelines
- **App Icon Generation** - Generate iOS, macOS, and Android app icons from a single source
- **Favicon Generation** - Generate all required favicon sizes and formats
- **SVG Optimization** - Minify and optimize SVG files via SVGO
- **Image Placeholders** - Generate ThumbHash and BlurHash placeholders
- **Responsive Images** - Generate multiple sizes for responsive web design
- **Watermarking** - Add text or image watermarks
- **Image to SVG** - Convert raster images to SVG using potrace
- **Activity Share Cards** - Render route-aware square, story, and landscape social assets

## Supported Formats

| Format | Decode | Encode |
|--------|--------|--------|
| JPEG | Yes | Yes |
| PNG | Yes | Yes |
| WebP | Yes | Yes |
| AVIF | Yes | Yes |
| GIF | Yes | Yes |
| BMP | Yes | Yes |
| SVG | Yes | - |

## License

MIT

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