In your attempt, by the time we get to the clone, the original of 2.jpg is no longer available to be cloned. With more thought, I can't see a simple way to use clone in my script. The difficulty is that composite uses two input files but, if three are available, it will use the third as a mask. This messes up the natural way of using clones.
There is another method of preventing the re-read of 2.jpg: save it (with "-write") into a temporary memory area.
Code: Select all
convert ^
-size 900x400 xc:White ^
( 1.jpg -resize 824x516 -virtual-pixel None +distort SRT "330" -geometry -270-270 ) ^
-composite ^
( 2.jpg -write mpr:saved2 -resize 320x240 -virtual-pixel None +distort SRT "350" -geometry -30+200 ) ^
-composite ^
( mpr:saved2 -resize 400x300 -virtual-pixel None +distort SRT "330" -geometry +100-30 ) ^
-composite ^
( mpr:saved2 -resize 320x240 -virtual-pixel None +distort SRT "30" -geometry +500-100 ) ^
-composite ^
( 3.jpg -resize 800x600 -virtual-pixel None +distort SRT "330" -geometry +200-50 ) ^
-composite ^
x1.png
Here is the equivalent command using "-layers". Note that each "-geometry" needs to change to be "-repage".
Code: Select all
convert ^
-size 900x400 xc:White ^
-gravity Center ^
( 1.jpg -resize 824x516 -virtual-pixel None +distort SRT "330" -repage -270-270 ) ^
( 2.jpg -resize 320x240 -virtual-pixel None +distort SRT "350" -repage -30+200 ) ^
( 2.jpg -resize 400x300 -virtual-pixel None +distort SRT "330" -repage +100-30 ) ^
( 2.jpg -resize 320x240 -virtual-pixel None +distort SRT "30" -repage +500-100 ) ^
( 3.jpg -resize 800x600 -virtual-pixel None +distort SRT "330" -repage +200-50 ) ^
-layers flatten ^
y.png
This method creates six images, then combines them together. So it uses more memory than the composite method which creates two images, combines them, adds another image and combines it, etc.
And we can easily use clone with "-layers".
Code: Select all
convert ^
-size 900x400 xc:White ^
-gravity Center ^
( 1.jpg -resize 824x516 -virtual-pixel None +distort SRT "330" -repage -270-270 ) ^
2.jpg ^
( -clone 2 -resize 320x240 -virtual-pixel None +distort SRT "350" -repage -30+200 ) ^
( -clone 2 -resize 400x300 -virtual-pixel None +distort SRT "330" -repage +100-30 ) ^
( -clone 2 -resize 320x240 -virtual-pixel None +distort SRT "30" -repage +500-100 ) ^
-delete 2 ^
( 3.jpg -resize 800x600 -virtual-pixel None +distort SRT "330" -repage +200-50 ) ^
-layers flatten ^
y2.png
This uses seven images, one of which is 2.jpg, unchanged. This is cloned three times. We don't want the unchanged 2.jpg in the final result, so we delete it.
"-clone" counts from zero. So "-clone 0" would be the white canvas, "-clone 1" would be the changed 1.jpg, and "-clone 2" is 2.jpg unchanged.