Hello everyone,
I am trying to run image magick convert from Elixir. The command I am trying to replicate is…
$ convert -size 200x200 xc:Black -fill White -draw 'circle 100 100 100 1' -alpha Copy mask.png
Which is working fine in the shell. It generates a new image correctly.
And now I am trying to do this in the BEAM.
def build_mask(size) do
params = [
"-size",
"#{size}x#{size}",
"xc:Black",
"-fill",
"White",
"-draw",
"'circle 100 100 100 1'",
"-alpha",
"Copy",
"mask.png"
]
System.cmd(convert(), params)
end
defp convert() do
case System.cmd("which", ["convert"]) do
{convert_cmd, 0} -> String.trim_trailing(convert_cmd, "\n")
{_, 1} -> ""
end
end
which fails with
convert: non-conforming drawing primitive definition `circle 100 100 100 1' @ error/draw.c/RenderMVGContent/4397.
The problem is in these lines, if I comment them, the command is working.
"-draw",
"'circle 100 100 100 1'",
So my question is how to pass a quoted parameters like this ‘circle 100 100 100 1’.
I have been trying different combination, with escape, double quote and what not.
Does anybody hit the same problem trying to wrap convert command in the BEAM?
Thanks for taking time