Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
956 views
in Technique[技术] by (71.8m points)

imagemagick - Composite not transferring color in imagemagick7 vs imagemagick6

I build my app store icons using imagemagick. The process has been working for years with imagemagick6. The final step in the icon building proceed is to composite a blue square with white text and a rounded white rectangle. When I upgraded to imagemagick7, the final step produced a rounded black icon with white text. Here's the code in my shell script:

# build a file with the two text lines centered with different, large point sizes for each
# then resize to the proper width
convert
    -gravity center
    -background transparent
    -fill white
    -font ArialB
    -pointsize ${TEXTSIZE} label:"${TEXT}"
    -pointsize ${TEXT2SIZE} label:"${TEXT2}"
    -append
    -resize $TEXTWIDTH
    tmpText.png
# build a background image with a radial gradient
convert
    -gravity center
    -size ${ICONSIZE}x${ICONSIZE} radial-gradient:"rgb(0,50,255)"-"rgb(0,0,127)"
    tmpBase.png
# combine the two
composite
    -gravity center
    tmpText.png tmpBase.png $FILENAME

In imagemagick7 the final two files tmpText.png and tmpBase.png look correct, but the output does not. I tried several variations of the compositing step to no avail. I finally downgraded back to imagemagick6, and things started working again, but that's not a long-term solution. Any ideas?

question from:https://stackoverflow.com/questions/65601039/composite-not-transferring-color-in-imagemagick7-vs-imagemagick6

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

With ImageMagick 7, replace convert with magick. Also replace composite with magick composite.

So for IM 6:

convert
    -gravity center
    -background transparent
    -fill white
    -font ArialB
    -pointsize 24 label:"Testing1"
    -pointsize 24 label:"Testing2"
    -append
    -resize 200% 
    tmpText.png
# build a background image with a radial gradient
convert
    -gravity center
    -size 500x500 radial-gradient:"rgb(0,50,255)"-"rgb(0,0,127)"
    tmpBase.png
# combine the two
composite
    -gravity center
    tmpText.png tmpBase.png fred_test6.png

I get:

enter image description here

And for IM 7

magick
    -gravity center
    -background transparent
    -fill white
    -font ArialB
    -pointsize 24 label:"Testing1"
    -pointsize 24 label:"Testing2"
    -append
    -resize 200% 
    tmpText.png
# build a background image with a radial gradient
magick
    -gravity center
    -size 500x500 radial-gradient:"rgb(0,50,255)"-"rgb(0,0,127)"
    tmpBase.png
# combine the two
magick composite
    -gravity center
    tmpText.png tmpBase.png fred_test7.png

I get:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...