我在 Elixir 中使用 Mogrify 包时遇到了问题。我想给一张图片添加文字。不知何故,这张图片可以打开并保存副本,但我无法对副本进行任何更改。
在 Iex 中的输出如下:
我尝试使用“自定义”添加填充和描边。我尝试使用“标签”,“绘制文本”和“注释”。最终保存的图像仅是原始图像的副本。
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)
在 Iex 中的输出如下:
===== 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
}
我尝试使用“自定义”添加填充和描边。我尝试使用“标签”,“绘制文本”和“注释”。最终保存的图像仅是原始图像的副本。