Horizontally center an image over another
Posted: 2014-07-11T23:02:13-07:00
I originally tried -gravity center -page +{x},+{y}, and discovered -gravity doesn't affect -page. I found a forum post with a similar issue, and have studied all the links and am just barely missing getting it right despite having tried all sorts of combinations.
What I'm trying to do is create two layers. (This is a reduced case from what I'm actually doing, I know there's simpler ways to achieve just what's shown here.)
Layer 1 - A white background
Layer 2 - A text box with a bit of space around it and a black line around it.
I want Layer 2 to be positioned centered horizontally, but at a specific y coordinate. I don't care if it flows down from the specified y coordinate or is vertically centered on it - I can handle either of those cases.
This is my most recent try:
Almost works, but it's centered vertically on the entire canvas rather than around the y offset I'm trying to give of 50. The geometry argument doesn't seem to do anything. My intention with it is to specify that I want "mpr:textLabel" to be centered around the point at 500,50. (Centered horizontally on the whole canvas, but centered vertically around y=50.)
What I'm trying to do is create two layers. (This is a reduced case from what I'm actually doing, I know there's simpler ways to achieve just what's shown here.)
Layer 1 - A white background
Layer 2 - A text box with a bit of space around it and a black line around it.
I want Layer 2 to be positioned centered horizontally, but at a specific y coordinate. I don't care if it flows down from the specified y coordinate or is vertically centered on it - I can handle either of those cases.
This is my most recent try:
Code: Select all
convert \
\( -size 1000x1000 xc:white -write mpr:bg +delete \) \
\( -size 0x0 -background "#68EBFE" -fill black -pointsize 24 label:"This is a label which I want centered" -bordercolor "#68EBFE" -border 10x10 -bordercolor black -border 1x1 -write mpr:textLabel +delete \) \
\( mpr:bg -gravity center -geometry +500+50 mpr:textLabel -composite -write output.jpeg +delete \) \
null: null: