Page 1 of 1

Help with background and centering

Posted: 2020-03-13T08:51:00-07:00
by colorful
convert -size 800x600 -background gray -gravity center -flatten in.png out.png

I am trying to create a 800x600 image. Background be gray. Paste in.png in the center.

What am I doing wrong?

Re: Help with background and centering

Posted: 2020-03-13T08:57:19-07:00
by fmw42
-flatten uses -page to do offset and does not respect -gravity. Use -compose over -composite. Also -background does not create the background image. Use xc: or canvas:

Code: Select all

convert -size 800x600 xc:gray in.png -gravity center -compose over -composite out.png
See

https://imagemagick.org/Usage/layers/
https://imagemagick.org/Usage/canvas/

Re: Help with background and centering

Posted: 2020-03-13T09:22:00-07:00
by GeeMack
colorful wrote:
2020-03-13T08:51:00-07:00
I am trying to create a 800x600 image. Background be gray. Paste in.png in the center.
You can create a gray canvas and composite your image onto it as fmw42 suggested. You can also use "-extent" to expand the canvas of the input image to your desired dimensions. Try this...

Code: Select all

convert in.png -background gray -gravity center -extent 800x600 out.png