我正在尝试使用 Erlang wxImage 库在 Elixir 中操作“test.jpg”图像,但出现错误。我不知道如何将数组/常量输出转换为列表,以便可以在 Elixir 中使用它。
另外我不知道为什么语法似乎没问题时会出现子句函数错误?
defmodule Imedit2 do
def readimg(image) do
{:ok, _file} = File.open("happy737.txt", [:write])
IO.puts("hi there")
_output =
image
|> File.read!()
|> :wxImage.getData()
|> to_charlist()
# IO.puts(is_list(output))
# IO.puts(is_tuple(output))
# IO.binwrite(file, output)
# File.close(file)
end
end
iex(58)> Imedit2.readimg("test.jpg")
hi there
** (FunctionClauseError) no function clause matching in :wxImage.getData/1
The following arguments were given to :wxImage.getData/1:
# 1
<<255, 216, 255, 226, 2, 28, 73, 67, 67, 95, 80, 82, 79, 70, 73, 76, 69, 0, 1,
1, 0, 0, 2, 12, 108, 99, 109, 115, 2, 16, 0, 0, 109, 110, 116, 114, 82, 71,
66, 32, 88, 89, 90, 32, 7, 220, 0, 1, 0, 25, ...>>
gen/wxImage.erl:405: :wxImage.getData/1
lib/imedit2.ex:5: Imedit2.readimg/1