This question: Use ImageMagick to place an image inside a larger canvas is something I've already done, but I'd like to modify it such that the new area is of a different colour without having the transparent part of the original image becoming the same colour.
How would this be accomplished?
Edit:
Input image:
xxxxxxxx
xx...xxx
xxxxxxxx
Output image:
xxxxxxxxiii
xx...xxxiii
xxxxxxxxiii
iiiiiiiiiii
- Xs (
x
) represent the original image. - Dots (
.
) represent transparent pixels. - Is (
i
) represent the background colour of the new canvas.
My command that I've thought of is something like this:
dwidth = newWidth-origWidth
dheight = newHeight-origHeight
convert in.png -background yellow -splice (dwidth)x(height)+(origHeight)+(0) -splice (width)x(dheight)+(0)+(origHeight) out.png
Parentheses are for clarity only. Actual numbers would show up instead without parentheses.
That code actually crashed. Using -gravity stopped the crash for some reason.
Using ImageMagick 6.9.1-Q16
.