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

1
  • N.B. I tried removing the '-geometry +0+0' arguments. It seemed to produce the same result. Commented Oct 27, 2017 at 14:49

1 Answer 1

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
2
  • Exactlyu as desired! Commented Oct 28, 2017 at 12:25
  • Awesome! Glad to hear it. =) Commented Oct 28, 2017 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .