ImageMagick convert: Placing text on a book cover

1

I am trying to make an eBook cover via ImageMagick, to be incorporated in a larger project after it works.

I want to get to geometry and gravity later, but at present I have two relevant images:

  1. A 1000x1600 JPEG background, which I lightened via GIMP enough so that it has no black or near-black pixels, and

  2. An 800x70 PNG author name with a single piece of text saved as black text against a transparent background.

(At present the 800x70 image is generated by Pango, and there may strictly be more options than compositing images; I expect it is possible to create a title and author name via Pango and circumvent image compositing. However, I would like to know that in addition to, and not instead of, a basic invocation for image compositing that would place a PNG with alpha over a JPEG, and be able to control its position with -gravity and -geometry.)

I am trying to go off of ImageMagick's layering examples, and have tried a few variations of the following:

convert -size 1000x1600 -geometry +0+0 \
  -composite background.jpg -gravity center -geometry +0+0 \
  -composite author.png -gravity center -geometry +0+0 \
  result.jpg

What I get from this is an 800x70 solid black image, which I would expect to be what you get when taking transparency from a PNG like the author name to make a JPEG.

What should I be doing to (for now at least) get to the point where I have a 1000x1600 result image equal to the background with the author name placed on it in some intelligible place?

Thanks

Christos Hayward

Posted 2017-10-26T21:38:25.000

Reputation: 753

N.B. I tried removing the '-geometry +0+0' arguments. It seemed to produce the same result. – Christos Hayward – 2017-10-27T14:49:06.770

Answers

1

Two issues:

  • You shouldn't need the convert command for this operation.

  • Your images are backwards in the command (the first image is the image to overlay on the second i.e. author then background).

This should give the results you want:

composite author.png -gravity center -geometry +0+0 \
background.jpg -gravity center -geometry +0+0 result.jpg

Arguably, you likely don't even need the second gravity/geometry combo:

composite author.png -gravity center -geometry +0+0 background.jpg result.jpg

Anaksunaman

Posted 2017-10-26T21:38:25.000

Reputation: 9 278

Exactlyu as desired! – Christos Hayward – 2017-10-28T12:25:01.497

Awesome! Glad to hear it. =) – Anaksunaman – 2017-10-28T12:27:47.610