antecessor
antecessor

Reputation: 2800

Combine two ImageMagick codes in a Script from Linux

Thanks to different forums, I could solve two issues separately:

Taking the images of the first link, I tried to combine both codes.

What I want is to run both codes automatically.

Concerning the text, the code must identify properly the filename of the background image and place in the middle. Sometimes, the filename is so large that does not fit the area, so it must be written in two lines. There must be a white background with 75% of opacity in the text, going some pixels at the top-bottom-left-right margins of the text.

The order of the the script is:

  1. Blend the logo to the southwest area of the fractal image.
  2. Place the name of the fractal in the middle of the previous combination.

I tried different ways, but I copy/paste here both independent codes. The one concerning the text should fulfill the requirements said previously.

convert 1.png \( 2.png -resize 60% -gravity west -chop 80x0 \) -gravity southwest -define compose:args=75 -compose blend -composite 1_2_b.png

filename=`convert "2.png" -ping -format "%t" info:`
convert "2.png" -fill black -undercolor white \
-gravity center -pointsize 30 -annotate +0+0 "$filename" \
 lena_label.jpg

Upvotes: 0

Views: 52

Answers (1)

fmw42
fmw42

Reputation: 53081

You can do that as follows in ImageMagick 6.

convert 1.png -set option:f "%f" \( 2.png -resize 50% \) \
-gravity southwest -define compose:args=75 -compose blend -composite \
-undercolor white -fill black -gravity south -font arial -pointsize 18 \
-annotate +0+0 "%[f]" 1_2.png


enter image description here

For ImageMagick 7, replace convert with magick.

Upvotes: 1

Related Questions