SOLVED - How to generate gradient background in montage?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
teracow
Posts: 19
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

SOLVED - How to generate gradient background in montage?

Post 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.
Last edited by teracow on 2016-06-08T00:13:26-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to generate gradient background in montage?

Post by fmw42 »

set the background to none and composite the montage output over a gradient of the same size.
User avatar
teracow
Posts: 19
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

Re: How to generate gradient background in montage?

Post 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. :)
Post Reply