-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgutils.ex
47 lines (41 loc) · 1.23 KB
/
imgutils.ex
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
defmodule ImgUtils do
@moduledoc """
Collection of image processing utilities.
"""
@on_load :load_nifs
@doc """
Resize an image.
## Examples
iex(1)> image = <<255, 0, 0, 0, 255, 0, 0, 0, 255>>
iex(2)> width = 3; height = 1; channels = 3; out_width = 3; out_height = 5
iex(3)> ImgUtils.resize(image, width, height, channels, out_width, out_height)
{:ok,
<<241, 14, 0, 14, 227, 14, 0, 14, 241, 241, 14, 0, 14, 227, 14, 0, 14, 241,
241, 14, 0, 14, 227, 14, 0, 14, 241, 241, 14, 0, 14, 227, 14, 0, 14, 241,
241, 14, 0, 14, 227, 14, 0, 14, 241>>}
"""
@spec resize(
in_content :: binary,
in_width :: pos_integer,
in_height :: pos_integer,
num_channels :: pos_integer,
out_width :: pos_integer,
out_height :: pos_integer
) :: {:ok, binary} | {:error, :resize}
def resize(
_in_binary,
_in_width,
_in_height,
_num_channels,
_out_width,
_out_height
) do
# coveralls-ignore-start
:erlang.nif_error(:nif_not_loaded)
# coveralls-ignore-stop
end
@doc false
def load_nifs do
:ok = :erlang.load_nif(Application.app_dir(:imgutils, "priv/imgutils"), 0)
end
end