package bimage

  1. Overview
  2. Docs

Source file impl.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
open Util
open Image

let kernel k ?output image =
  let output =
    match output with
    | Some d ->
        d
    | None ->
        like image
  in
  let f = Op.kernel k in
  Op.eval f ~output [|image|];
  output


let rotate_90 image =
  let output = create (kind image) image.color image.height image.width in
  let center =
    (float_of_int output.width /. 2., float_of_int image.height /. 2.)
  in
  Op.(eval (rotate ~center (Angle.of_degrees 90.))) ~output [|image|];
  output


let rotate_180 image =
  let output = create (kind image) image.color image.width image.height in
  let center =
    (float_of_int image.width /. 2., float_of_int image.height /. 2.)
  in
  Op.(eval (rotate ~center (Angle.of_degrees 180.))) ~output [|image|];
  output


let rotate_270 image =
  let output = create (kind image) image.color image.height image.width in
  let center =
    (float_of_int image.width /. 2., float_of_int output.height /. 2.)
  in
  Op.(eval (rotate ~center (Angle.of_degrees 270.))) ~output [|image|];
  output


let resize width height image =
  let output = create (kind image) image.color width height in
  let x = float_of_int width /. float_of_int image.width in
  let y = float_of_int height /. float_of_int image.height in
  Op.(eval (scale x y) ~output [|image|]);
  output