Overlapping images and swap

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
drugis
Posts: 2
Joined: 2020-01-24T03:16:28-07:00
Authentication code: 1152

Overlapping images and swap

Post by drugis »

I have the following bash script:

Code: Select all

#!/bin/bash
convert -size 100x100 xc:red red.png
convert -size 100x100 xc:green green.png
convert -size 100x100 xc:blue blue.png

convert red.png -alpha set -virtual-pixel transparent  +distort affine '0,90 10,10 99,90 99,20' green.png -alpha set -virtual-pixel transparent +distort affine '0,90 10,10 99,90 99,20' blue.png -alpha set -virtual-pixel transparent   -background transparent -layers merge +repage rgb.png
 
This works fine with blue overlapping green and then overlapping red. Image

Now, what I want is red overlapping green overlapping blue.
I tried with +swap after green.png and blue.png but do not get a proper result.
Note: I need the +distort affine for my final script.

Does anybody know how to swap the images on top of each other?

Version: ImageMagick 6.7.8-9 2019-08-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

snibgo
Posts: 12926
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overlapping images and swap

Post by snibgo »

Swap images #0 and #2:

Code: Select all

convert \
  red.png -alpha set -virtual-pixel transparent  +distort affine '0,90 10,10 99,90 99,20' \
  green.png -alpha set -virtual-pixel transparent +distort affine '0,90 10,10 99,90 99,20' \
  blue.png -alpha set -virtual-pixel transparent   \
  -swap 0,2 \
  -background transparent -layers merge +repage \
  overrgb_swap.png
Image
Is that what you want?
snibgo's IM pages: im.snibgo.com

drugis
Posts: 2
Joined: 2020-01-24T03:16:28-07:00
Authentication code: 1152

Re: Overlapping images and swap

Post by drugis »

Thank you snibgo, exactly what I want!

Post Reply