Imagemagick弧
您好,我在使用Imagemagick创建内容时遇到问题 以下是脚本:Imagemagick弧,imagemagick,automatic-ref-counting,Imagemagick,Automatic Ref Counting,您好,我在使用Imagemagick创建内容时遇到问题 以下是脚本: convert -size 300x300 xc:skyblue -background none -fill #AF280E -stroke none -draw "circle 150,150 75,250" -fill white -stroke none -draw "circle 150,150 75,240" -fill #D3DADF -stroke n
convert
-size 300x300 xc:skyblue
-background none
-fill #AF280E
-stroke none
-draw "circle 150,150 75,250"
-fill white
-stroke none
-draw "circle 150,150 75,240"
-fill #D3DADF
-stroke none
-draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"'
-fill #AF280E
-stroke none
-draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"'
-fill white
-stroke none
-draw "rectangle 290,140 10,170"
-fill white
-stroke #AF280E
-strokewidth 5
-draw "line 10,137 290,137"
-strokewidth 40
-fill white
-stroke #D3DADF
-strokewidth 5
-draw "line 10,170 290,170"
-strokewidth 40
-fill white
-stroke none
-annotate 100,50
-draw "circle 150,150 75,150"
-background none
-font Bookman-Light
-pointsize 12
-fill navy label"arc text here"
-distort Arc 340
logo_2_b6.gif
我想将圆弧文本放置在这些圆上,但它一直闪烁,甚至连圆弧所在的形状也会闪烁。使用ImageMagick命令时,您的命令行中有几个错误 让我们把它写得更可读一点,并在每个步骤后添加临时文件的写入。这是代码的Unix语法:
convert -size 300x300 xc:skyblue +write t1.png \
-background none -fill #AF280E -stroke none -draw "circle 150,150 75,250" +write t2.png \
-fill white -stroke none -draw "circle 150,150 75,240" +write t3.png \
-fill #D3DADF -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' +write t4.png \
-fill #AF280E -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' +write t5.png \
-fill white -stroke none -draw "rectangle 290,140 10,170" +write t6.png \
-fill white -stroke #AF280E -strokewidth 5 -draw "line 10,137 290,137" +write t7.png \
-strokewidth 40 -fill white -stroke #D3DADF -strokewidth 5 -draw "line 10,170 290,170" +write t8.png \
-strokewidth 40 -fill white -stroke none -annotate 100,50 +write t9.png \
-draw "circle 150,150 75,150" +write t10.png \
-background none -font Bookman-Light -pointsize 12 -fill navy label:"arc text here" +write t11.png \
-distort Arc 340 logo_2_b6.gif
convert -size 300x300 xc:skyblue +write t1.png \
-background none -fill "#AF280E" -stroke none -draw "circle 150,150 75,250" +write t2.png \
-fill white -stroke none -draw "circle 150,150 75,240" +write t3.png \
-fill "#D3DADF" -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' +write t4.png \
-fill "#AF280E" -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' +write t5.png \
-fill white -stroke none -draw "rectangle 290,140 10,170" +write t6.png \
-fill white -stroke "#AF280E" -strokewidth 5 -draw "line 10,137 290,137" +write t7.png \
-strokewidth 40 -fill white -stroke "#D3DADF" -strokewidth 5 -draw "line 10,170 290,170" +write t8.png \
-strokewidth 40 -fill white -stroke none -annotate +100+50 " " +write t9.png \
-draw "circle 150,150 75,150" +write t10.png \
-background none -font Arial -pointsize 12 -fill navy label:"arc text here" -compose over -composite +write t11.png \
-distort Arc 340 logo_2_b6.gif
在这里,我修复了您的代码:
convert -size 300x300 xc:skyblue +write t1.png \
-background none -fill #AF280E -stroke none -draw "circle 150,150 75,250" +write t2.png \
-fill white -stroke none -draw "circle 150,150 75,240" +write t3.png \
-fill #D3DADF -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' +write t4.png \
-fill #AF280E -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' +write t5.png \
-fill white -stroke none -draw "rectangle 290,140 10,170" +write t6.png \
-fill white -stroke #AF280E -strokewidth 5 -draw "line 10,137 290,137" +write t7.png \
-strokewidth 40 -fill white -stroke #D3DADF -strokewidth 5 -draw "line 10,170 290,170" +write t8.png \
-strokewidth 40 -fill white -stroke none -annotate 100,50 +write t9.png \
-draw "circle 150,150 75,150" +write t10.png \
-background none -font Bookman-Light -pointsize 12 -fill navy label:"arc text here" +write t11.png \
-distort Arc 340 logo_2_b6.gif
convert -size 300x300 xc:skyblue +write t1.png \
-background none -fill "#AF280E" -stroke none -draw "circle 150,150 75,250" +write t2.png \
-fill white -stroke none -draw "circle 150,150 75,240" +write t3.png \
-fill "#D3DADF" -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' +write t4.png \
-fill "#AF280E" -stroke none -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' +write t5.png \
-fill white -stroke none -draw "rectangle 290,140 10,170" +write t6.png \
-fill white -stroke "#AF280E" -strokewidth 5 -draw "line 10,137 290,137" +write t7.png \
-strokewidth 40 -fill white -stroke "#D3DADF" -strokewidth 5 -draw "line 10,170 290,170" +write t8.png \
-strokewidth 40 -fill white -stroke none -annotate +100+50 " " +write t9.png \
-draw "circle 150,150 75,150" +write t10.png \
-background none -font Arial -pointsize 12 -fill navy label:"arc text here" -compose over -composite +write t11.png \
-distort Arc 340 logo_2_b6.gif
首先,你以+write t9.png结尾的那行对我来说毫无意义。-annotate语法是-annotate+X+Y“sometext”。您的+X+Y语法错误(您有X,Y)。第二,你没有文本。你想干什么?请参见以t9.png结尾的等效行。我已经更正了您的语法并添加了一些空文本,因为我不知道您在这里试图做什么。 其次,失败的是你的标签。它必须是标签:“一些文本”。您省略了冒号(:) 第三,该行使您拥有两个版本的t11.png,即t11-0.png和t11-1.png。标签创建一个新图像。它不会在上一张图像上书写。因此,您需要添加-compose over-composite,以便在单个t11.png中显示它 它还有助于查看创建的每个图像,看看它是否为该步骤生成了正确的结果。 因此,我从命令中得到的是:
正如前面提到的fmw42一样,您的命令有几个问题。考虑一些改进… 填充颜色、笔划颜色和笔划宽度等的单个设置将适用于以下所有操作,直到您需要更改它们为止。您不必这样做,但它可以帮助您减少代码的混乱 制作标签并在括号内进行圆弧扭曲,以避免扭曲先前在命令中创建的徽标的其余部分。在创建曲线文本时,在“-扭曲圆弧”操作中指定外半径和内半径也很有帮助 您的输出是GIF,因此您需要在写入输出之前将文本“-合成”到徽标图形上,否则IM将生成动画GIF,并且您的文本将闪烁 下面是一个在bashshell中运行的IMv6.8.9上适用的命令。它可能会帮助你朝着一个好的方向前进
convert -size 300x300 xc:skyblue +size -background none \
-stroke none \
-fill "#AF280E" -draw "circle 150,150 75,250" \
-fill white -draw "circle 150,150 75,240" \
-fill "#D3DADF" -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' \
-fill "#AF280E" -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' \
-fill white -draw "rectangle 290,140 10,170" \
-strokewidth 5 \
-fill white \
-stroke "#AF280E" -draw "line 10,137 290,137" \
-stroke "#D3DADF" -draw "line 10,170 290,170" \
-strokewidth 40 \
-stroke none -draw "circle 150,150 75,150" \
+strokewidth \
\( -font Bookman-Light -pointsize 36 -fill navy -virtual-pixel none \
label:"arc text here" -distort Arc "340 0 68" \) \
+repage -gravity center -composite logo_2_b6.gif
编辑以添加:
我添加了另一个“标签:”并调整了半径以生成第二条文本,并使其与第一条文本兼容。在弧线变形之前,必须将其旋转,以使文字正确朝上
convert -size 300x300 xc:skyblue +size -background none \
-stroke none \
-fill "#AF280E" -draw "circle 150,150 75,250" \
-fill white -draw "circle 150,150 75,240" \
-fill "#D3DADF" -draw 'path "M 260 150 A 1 1,0,0 ,1 ,41 150"' \
-fill "#AF280E" -draw 'path "M 260 150 A 1 1,0,0 ,0 ,41 150"' \
-fill white -draw "rectangle 290,140 10,170" \
-strokewidth 5 \
-fill white \
-stroke "#AF280E" -draw "line 10,137 290,137" \
-stroke "#D3DADF" -draw "line 10,170 290,170" \
-strokewidth 40 \
-stroke none -draw "circle 150,150 75,150" \
+strokewidth \
-gravity center \
\( -font Bookman-Light -pointsize 48 \
-fill "#D3DADF" -virtual-pixel none \
label:"\ upper arc " \
-distort Arc "360 0 115" \) \
-gravity center \
+repage -composite \
\( -font Bookman-Light -pointsize 48 \
-fill navy -virtual-pixel none \
label:"\ lower arc " \
-rotate 180 -distort Arc "360 180 115" \) \
+repage -composite logo_2_b8.gif
在ImageMagick中处理弯曲文本区域可能非常具有挑战性。注意,我必须添加空格并进行旋转,以确保两个文本标签在大小和中心位置上相互匹配。不同的字体、不同数量的文本,甚至在不同的机器上使用相同的字体名称,都会影响文本的确切位置
学习“”操作可能有助于创建和对齐圆形图像。您好,谢谢您。这是我正在尝试做的。文本应该是褐红色区域的圆弧,然后是灰色区域的另一个圆弧文本。有关另一个示例命令和注释,请参阅我在第一个解决方案中添加的内容。谢谢,看起来不错,但是为什么我的结果与你的不同呢?我运行的是bash shell的第7版。你的圆弧扭曲必须保留在括号内,否则会影响图像的其他部分。这似乎就是正在发生的事情。确保所有括号都用反斜杠“\(…\)”转义。我曾尝试在每个脚本上加反斜杠,但它仍然会影响圆圈甚至背景。然后我试着把arc脚本放在第一位,这就是结果。()谢谢你的帮助,我会努力找出我的剧本。