Page 1 of 1

Add top header to final generated image

Posted: 2018-11-12T22:47:41-07:00
by cgkas
Hello to all,

Please some help here. I´m using IM 6.9.10-11 Q16 x86_64

After several people that have helped me, I have this coordinates and this script.

The coordinates correlative are related with the box number in input image. The first 3 lines creates a
header text "Left - Right" that goes over the img2.png and img3.png

Code: Select all

coord1="98x35+234+16" 
coord2="178x59+29+65"
coord3="178x59+223+65"
coord4="178x59+417+65"
coord5="178x59+611+65"
coord6="239x147+35+179" 
coord7="239x147+416+179"
coord8="239x147+73+349"
coord9="239x147+401+353"    
   
convert \
\( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Left" \) \
\( -size 125x36 xc:"#00137F" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Right" \) \
 -background white +smush +2 -write mpr:leftright +delete +gravity \
 \
input.png +repage -write mpr:img -delete 0--1 -background none -bordercolor "#870000"  \
\( mpr:img -crop $coord2 \)  \
\( mpr:img -crop $coord3 \)  \
\( mpr:img -crop $coord4 \)  \
\( mpr:img -crop $coord5 \)  \
-border 4 \( -clone 0,1 -smush -4 \) \( -clone 2,3 -smush -4 \) -delete 0-3 -gravity center +smush -4 +gravity \
\( mpr:img -crop $coord1 -border 4 \) +swap -gravity center -smush +12 +gravity -write Img1.png \
 \
\( \( mpr:img -crop $coord6 +repage -border 4 \) \( mpr:img -crop $coord7 +repage -border 4 \) \
   +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity  -write Img2.png  \) -delete 0--1 \
\
\( \( mpr:img -crop $coord8 +repage -border 4 \) \( mpr:img -crop $coord9 +repage -border 4 \) \
   +smush +6 mpr:leftright +swap -gravity center -smush +11 +gravity  -write Img3.png  \) null:  

With this input.png
Image

The code produces this 3 images.

Img1.png
Image

Img2.png
Image

Img3.png
Image

What I´d like is to modifiy the current code to add a top header text to each one of these 3 images
before be created (before -write) in order that the Img1, Img2 and Img3 be finally like this:

Desired Img1.png
Image

Desired Img2.png
Image

Desired Img3.png
Image

I think I need to create the images first at the beginning of the convert command, something like this, but I don´t know how to adapt the code.

Code: Select all

\( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Five boxes" \) \
\( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Blue boxes" \) \
\( -size 500x36 xc:"#757575" -fill white -font Calibri-Bold -pointsize 32 -gravity center -annotate +0+0 "Green boxes" \) \
Thanks for any help.