Page 1 of 1

SOLVED - How to generate gradient background in montage?

Posted: 2016-06-07T22:24:41-07:00
by teracow
Hello,

using: ImageMagick 6.8.9-8 Q16 x86_64 2016-05-05
on: OpenSUSE 13.2 64b

Is there a way to generate a gradient fill for the background in montage? I've only seen solid colours used in examples. And the default (white) is a little hard on the eyes... ;)

I'd like to do a diagonal gradient from light grey to dark grey if that's possible? Can someone please instruct me here?

Thanks.

Re: How to generate gradient background in montage?

Posted: 2016-06-07T22:34:54-07:00
by fmw42
set the background to none and composite the montage output over a gradient of the same size.

Re: How to generate gradient background in montage?

Posted: 2016-06-08T00:13:05-07:00
by teracow
So, I did this:

Code: Select all

#!/bin/bash

# build gallery
montage "*[0]" -background none -shadow -geometry 400x400 "gallery-foreground.png"

# get image dimensions
read -r width height <<< $(convert -ping "gallery-foreground.png" -format "%w %h" info:)

# create a black image with white sphere in centre
convert -size ${width}x${height} radial-gradient:white-black "gallery-background.png"

# overlay foreground on background
composite -gravity center "gallery-foreground.png" "gallery-background.png" "gallery-actual.png"
Works well!

Thanks Fred. :)