Liking cljdoc? Tell your friends :D

ol.vips

High-perf image processing for Clojure built with libvips.

This package wraps the core functionality of libvips image processing library by exposing all native image operations as data and functions to Clojure programs.

We use coffi along with Java 22+ FFM (aka Project Panama) is used to provide speed and efficient native bridging.

Installation

Install the main library plus exactly one native jar that matches your target platform.

;; deps.edn
{:deps {com.outskirtslabs/vips {:mvn/version "0.0.1"}
        com.outskirtslabs/vips-native-linux-x86_64-gnu  {:mvn/version "1.2.4-0"}}}

Choose one native artifact:

  • com.outskirtslabs/vips-native-linux-x86-64-gnu
  • com.outskirtslabs/vips-native-linux-x86-64-musl
  • com.outskirtslabs/vips-native-linux-aarch64-gnu
  • com.outskirtslabs/vips-native-linux-aarch64-musl
  • com.outskirtslabs/vips-native-macos-x86-64
  • com.outskirtslabs/vips-native-macos-aarch64
  • com.outskirtslabs/vips-native-win32-x86-64

ol.vips requires Java 22+ and native access enabled for the JVM process:

;; deps.edn
{:aliases
 {:dev {:jvm-opts ["--enable-native-access=ALL-UNNAMED"]}}}

The library bundles platform-specific native artifacts for supported Linux, macOS, and Windows targets.

Quick Start

(require '[ol.vips :as v]
         '[ol.vips.operations :as ops])

(v/init!)

(with-open [image   (v/from-file "dev/rabbit.jpg")
            thumb   (v/thumbnail image 300 {:auto-rotate true})
            rotated (ops/rotate thumb 90.0)]
  (v/write-to-file rotated "thumbnail.jpg")
  (v/info rotated))
;; => {:width 300, :height 242, :bands 3, :has-alpha? false}

The top-level ol.vips namespace provides the image loading, saving, metadata, and convenience helpers. ol.vips.operations contains generated wrappers for libvips operations.

Common Operations

Reading And Writing

(with-open [image (v/from-file "dev/rabbit.jpg" {:shrink 2})]
  (v/info image)
  (v/shape image)
  (v/write-to-file image "rabbit.png" {:compression 9})
  (v/write-to-buffer image ".png" {:compression 9}))

Autorotate And Inspect Outputs

autorot returns a closeable result map. You can inspect :angle and :flip, and still use the same value anywhere an image is expected.

(with-open [image   (v/from-file "dev/rabbit.jpg")
            autorot (ops/autorot image)]
  {:angle (:angle autorot)
   :flip  (:flip autorot)
   :info  (v/info autorot)})
;; => {:angle :d0, :flip false, :info {:width 2490, :height 3084, :bands 3, :has-alpha? false}}

Resize And Crop

(with-open [image   (v/from-file "dev/rabbit.jpg")
            resized (ops/resize image 0.5)
            cropped (ops/extract-area resized 100 100 500 500)]
  (v/write-to-file resized "rabbit-resized.jpg")
  (v/write-to-file cropped "rabbit-cropped.jpg")
  {:resized (v/info resized)
   :cropped (v/info cropped)})

Transforming Images

(with-open [image   (v/from-file "dev/rabbit.jpg")
            rotated (ops/rotate image 90.0)
            flipped (ops/flip rotated :horizontal)
            bw      (ops/colourspace flipped :b-w)]
  (v/write-to-file bw "rabbit-bw.jpg"))

Filters And Effects

(with-open [image   (v/from-file "dev/rabbit.jpg")
            blurred (ops/gaussblur image 3.0)
            sharp   (ops/sharpen image {:sigma 1.0})]
  (v/write-to-file blurred "rabbit-blur.jpg")
  (v/write-to-file sharp "rabbit-sharp.jpg")
  {:blurred (v/info blurred)
   :sharp   (v/info sharp)})

Composing Images

(with-open [left   (v/from-file "dev/rabbit.jpg")
            right  (v/from-file "dev/rabbit.jpg")
            joined (ops/join left right :horizontal)
            grid   (ops/arrayjoin [left right left right]
                                  {:across 2
                                   :shim   10
                                   :halign :centre
                                   :valign :centre})]
  (v/write-to-file joined "rabbit-joined.jpg")
  (v/write-to-file grid "rabbit-grid.jpg"))

Web Optimization

(with-open [image (v/from-file "dev/rabbit.jpg")]
  (v/write-to-file image "rabbit-progressive.jpg"
                   {:interlace true
                    :strip true
                    :Q 85})
  (v/write-to-file image "rabbit.webp"
                   {:Q 80
                    :effort 4}))

Calling Raw Operations

(with-open [image   (v/from-file "dev/rabbit.jpg")
            rotated (v/call! "rotate" {:in image :angle 90.0})]
  (v/info rotated))

Use v/operations to list available libvips operations and v/operation-info to inspect their inputs and outputs.

Why libvips?

  • Blazing fast and memory efficient
  • Comprehensive format support - handles all major image formats (JPEG, PNG, WebP, TIFF, HEIF, AVIF) without extra libraries or need to exec external programs
  • 300 operations covering arithmetic, histograms, convolution, morphological operations, frequency filtering, colour, resampling, statistics and others.

Licensing

The Clojure library ol.vips is copyright (C) 2026 Casey Link and is licensed under EUPL-1.2.

The platform-native companion jars under native/ redistribute upstream sharp-libvips binary bundles. Those redistributed native binaries are licensed separately from the ol.vips source, principally under LGPL-3.0-or-later, with additional bundled third-party component notices documented in THIRD-PARTY-NOTICES.md.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close