我已在 Windows 上安装了 ImageMagick v7.0.10-26,并从 cmd 行运行它。我尚未安装convert
。
此示例从以下位置创建两个新的图像文件,并按指定要求进行修改existingimage.png
:
magick existingimage.png -gravity south -fill white -pointsize 150 -annotate +0+20 "Hello World" -write newimage1.gif newimage2.gif
当我newimage2.gif
从命令中删除时,会magick
出现以下抱怨(并且不输出任何图像):
magick: MissingArgument `-write' at CLI arg 11 @ fatal/magick-cli.c/ProcessCommandOptions/447.
为什么-write
需要两个参数?
答案1
为什么
-write
需要两个参数?
不需要。它需要一个参数,一个“中间”输出文件名。
您似乎误解了“最终”(完全处理)输出文件名(例如newimage2.gif
)是 的一部分-write
,但事实并非如此。任何最终输出文件名通常都是 的最后一个参数magick ...
:
# Create both an "intermediate" image processed with the
# options up to "-write filename" ("newimage1.gif") and
# a separate "final" image ("newimage2.gif") with those
# same options.
magick existingimage.png -gravity south -fill white -pointsize 150 -annotate +0+20 "Hello World" -write newimage1.gif newimage2.gif
# Create just a "final" image, processed with all the
# existing options in the given "magick" command.
# (no "-write filename" command needed)
magick existingimage.png -gravity south -fill white -pointsize 150 -annotate +0+20 "Hello World" newimage2.gif
# Create both an "intermediate" image processed with the
# options up to "-write filename" ("newimage1.gif") and
# a separate "final" image ("newimage2.gif") with additional
# options unique to it ("-resize 50%").
magick existingimage.png -gravity south -fill white -pointsize 150 -annotate +0+20 "Hello World" -write newimage1.gif -resize 50% newimage2.gif
# This produces an error. The "final" file name here for
# "magick ..." is "newimage1.gif" and "-write" has no
# "intermediate" file name specified.
magick existingimage.png -gravity south -fill white -pointsize 150 -annotate +0+20 "Hello World" -write newimage1.gif