mikera / imagez

Image processing library for Clojure
301 stars 38 forks source link

imagez

Image processing library for Clojure

Contains various utility functions for handling colours and bitmap images.

Clojars Project

Build Status

Example

(use 'mikera.image.core)
(require '[mikera.image.filters :as filt])

;; load an image from a resource file
(def ant (load-image-resource "mikera/image/samples/Ant.png"))

;; show the image, after applying an "invert" filter
(show (filter-image ant (filt/invert)))

Inverted ant

Features

Features so far:

Imagez is a new library, so the API is being refined. Expect changes / additions on a regular basis.

Using Imagez

Simply add the dependency via Clojars: https://clojars.org/net.mikera/imagez

Imagez requires Clojure 1.4 and above.

More Examples

(use 'mikera.image.core)
(use 'mikera.image.colours)

;; create a new image
(def bi (new-image 32 32))

;; gets the pixels of the image, as an int array
(def pixels (get-pixels bi))

;; fill some random pixels with colours
(dotimes [i 1024]
  (aset pixels i (rand-colour)))

;; update the image with the newly changed pixel values
(set-pixels bi pixels)

;; view our new work of art
;; the zoom function will automatically interpolate the pixel values
(show bi :zoom 10.0 :title "Isn't it beautiful?")

For more examples including image filtering, see the demo namespace:

License

LGPL version 3.0.