Skip to content
Hokusai2.2.2
ivantokar.com
Hokusai logo

Hokusai

High-performance JPEG, PNG, WebP, AVIF, HEIF, TIFF, GIF, and PDF image processing powered by libvips.

Immutable pipelines

Compose transformations synchronously, branch safely across tasks, and evaluate only at an output terminal.

libvips powered

Process images on demand with small pixel regions and efficient native concurrency.

Native Swift integration

Use typed Swift APIs directly, with first-party Vapor and Hummingbird adapters.

Image-based PDFs

Export the evaluated pipeline as a Cairo-backed one-page PDF for reports and generated documents.

Hokusai is a Swift package for high-performance server-side image processing. It accepts Data, file URL, raw pixel and streamed upload inputs, provides typed JPEG, PNG, WebP, AVIF, HEIF, TIFF, GIF, and PDF outputs, and keeps blocking native evaluation away from Swift’s cooperative executor. These pages document Hokusai 2.2.2, Hokusai Vapor 2.1.0 and Hokusai Hummingbird 2.1.0.

  • High performance: libvips processes images efficiently without child processes.
  • Safe concurrency: immutable pipelines can be branched across tasks before output evaluation.
  • Typed output: choose JPEG, PNG, WebP, AVIF, HEIF, TIFF, GIF, or Cairo-backed PDF with Swift APIs.
  • Server integration: decode uploads and return correctly typed, streamed responses through Hokusai Vapor or Hokusai Hummingbird.
let thumbnail = try await Hokusai(url: URL(fileURLWithPath: "photo.jpg"))
.autoOrient()
.resize(width: 400)
.jpeg(quality: 85)
.write(to: URL(fileURLWithPath: "thumbnail.jpg"))