I'm having trouble with the Mogrify package in Elixir. I have an image that I want to add text to. For some reason the image will open and save a copy without any issues but I can't get the copy to be changed in any way.
img_url = to_string(:code.priv_dir(:jobs)) <> "/tristar.png"
save_url = to_string(:code.priv_dir(:jobs)) <> "/tristar_copy.png"
Mogrify.open(img_url)
|> Mogrify.custom("pointsize", 200)
|> Mogrify.custom("gravity", "North")
|> Mogrify.custom("annotate", "+0,+100 'Testing'")
|> IO.inspect(label: "\n===== Image Pre-Save =============================================")
|> Mogrify.save(path: save_url)
The output in Iex looks like:
===== Image Pre-Save =============================================:
%Mogrify.Image{
animated: false,
buffer: nil,
dirty: %{},
ext: ".png",
format: nil,
frame_count: 1,
height: nil,
operations: [
{"pointsize", 200},
{"gravity", "North"},
{"annotate", "+0,+100 'Testing'"}
],
path: "/code/elixir/_build/dev/lib/jobs/priv/tristar.png",
width: nil
}
%Mogrify.Image{
animated: false,
buffer: nil,
dirty: %{},
ext: ".png",
format: nil,
frame_count: 1,
height: nil,
operations: [],
path: "/code/elixir/_build/dev/lib/jobs/priv/tristar_copy.png",
width: nil
}
I've tried adding fill and stroke with custom
. I've tried using label
, draw text
, and annotate
. The saved image at the end is simply a copy of the original.
You are one comma away from a working solution:
Change "+0,+100 'Testing'"
to "+0+100 'Testing'"
.