A small Clojure(Script) library for reading and writing Netpbm format. Currently supports p1 (.pbm), p2 (.pgm) and p3 (.ppm) formats.
Good explanation of the format can be found here and here.
For more info check out the repo here.
Some code samples:
;; read the pbm format
(require '[clj-pnm.core :as pnm])
=> nil
(def pbm
"P1
2
2
1 1
1 1")
=> #'user/pbm
(pnm/read-pnm pbm)
=> {:type :p1, :width 2, :height 2, :map [[1 1] [1 1]]}
;; read the *pgm* format
(def pgm
"P2
3
2
4
1 2 3
4 3 2")
=> #'user/pgm
(pnm/read-pnm pgm)
=> {:type :p2, :width 3, :height 2, :max-value 4, :map [[1 2 3] [4 3 2]]}
;; read the *ppm* format
(def ppm
"P3
2
2
255
255 0 255 128 52 123
0 0 0 45 45 45")
=> #'user/ppm
(pnm/read-pnm ppm)
=> {:type :p3
:width 2
:height 2
:max-value 255
:map [[(255 0 255) (128 52 123)]
[(0 0 0) (45 45 45)]]} ; prettified