nasaa
nasaa

Reputation: 2731

Image magick to put images in row and then generate reflection

I was wondering if I can use imagemagick to produce a result image like this

enter image description here

My initial image will be like this

enter image description here

I am able to create the dark image to be put in the background like this -

convert -brightness-contrast -20x10 GARDENS-ILLUSTRATED_JAN-14.jpg out_lighter2.jpg

But I do not know how to put them in line like that and then generate a reflection.

Upvotes: 0

Views: 74

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207520

I have got something close, but have no more time, so maybe you can fiddle with it and get it to what you want:

#!/bin/bash
input=input.png

# Calculate width and height
w=$(convert $input -ping -format "%w" info:)
h=$(convert $input -ping -format "%h" info:)

# Calculate how much to chop off bottom and height of reflection
chop=$(echo $h*60/100|bc)
refl=$(echo $h*20/100|bc)
convert $input -alpha on \
      \( +clone -flip -size ${w}x${refl} gradient:gray40-black -alpha off -compose CopyOpacity -composite \) \
      -append -background white -compose Over -flatten -gravity South -chop 0x${chop} output1.png

# Darken and reduce for second layer
convert output1.png -brightness-contrast -25x8 -resize 90% output2.png

# Darken and reduce for third layer
convert output2.png -brightness-contrast -25x8 -resize 90% output3.png

# Make big new output canvas
neww=$(echo $w*1.6|bc)
newh=$(echo $h*1.6|bc)

# Splat images onto it with offsets
convert -size ${neww}x${newh} xc:transparent -page +0+80 output3.png \
    -page +40+40 output2.png \
    -page +80+0 output1.png -flatten output.png

My basic idea is to generate the bright, frontmost image first in output1.png, then darken and reduce it into output2.png and again into output3.png. Then composite them all together into output.png with a little offset.

enter image description here

Upvotes: 2

Related Questions