Page
Library
Module
Module type
Parameter
Class
Class type
Source
%%VERSION%%
bimage is an image processing library for OCaml.
bimage-unix)bimage-gtk) or SDL (bimage-sdl)bimage is distributed under the ISC license.
Homepage: https://github.com/zshipko/bimage
bimage can be installed with opam:
opam install bimageAdditionally, bimage-unix, which provides ImageMagick and FFmpeg bindings, can be installed by running:
opam install bimage-unixIf you don't use opam consult the opam file for build instructions.
An example showing how to create an image and how to use Image.for_each:
open Bimage
let _ =
(* Create a new image *)
let a = Image.create u8 gray 64 64 in
(* Iterate over each pixel *)
let _ =
Image.for_each (fun x y _px ->
set a x y (x + y)
) a
in
(* Save the image using ImageMagick *)
Bimage_unix.Magick.write "test1.jpg" aAn example using Op.t to run a filter on an image:
open Bimage
open Bimage_unix
let _ =
(* Load an image using ImageMagick *)
let Some a = Magick.read "test/test.jpg" f32 rgb in
(* Create an operation to convert to grayscale and subtract 1.0 *)
let f = Op.(grayscale &- scalar 1.0) in
(* Create a destination image *)
let dest = Image.like f32 gray a in
(* Run the operation *)
let () = Op.eval f dest [| a |] in
(* Save the image using ImageMagick *)
Magick.write "test2.jpg" aThe documentation and API reference is generated from the source interfaces. It can be consulted online or via odig doc bimage.
In the distribution sample programs and tests are located in the test directory. They can be built and run with:
dune runtest