Page 1 of 1

Offset Stacked Images

Posted: 2012-03-03T13:56:55-07:00
by Wonkey Donkey
Hi all,

I'm having difficulty working out how to offset images which I have layered on top of one another by a specified amount. My code at present is as follows:

Code: Select all

convert "%FilePath%cathedral.jpg" "%FilePath%cathedral2.jpg"
-bordercolor white -border 6 -bordercolor grey60 -border 1 -bordercolor none -background none -gravity center
( -clone 0 -rotate -14.8837 )
( -clone 1 -rotate 17 )
( -clone 0 -rotate 5 -gravity center ( -rotate -12 "%FilePath%stamp.png" ) -composite )
-delete 0,1 -border 320x221 -crop 640x442+0+0 +repage -flatten -trim +repage -background black ( +clone -shadow 60x4+4+4 ) +swap -background none -flatten -resize 320x221^ "%FilePath%churchmicro.png"
Also, any other "optimisations" / simplifications people can provide to the above which either improve or do not deviate from the current result would be much appreciated.

Thanks in advance.

Version: ImageMagick 6.7.5-7 2012-02-23 Q16

Re: Offset Stacked Images

Posted: 2012-03-03T14:19:54-07:00
by Bonzo
Are you trying to acheve this effect: layers

Re: Offset Stacked Images

Posted: 2012-03-03T14:22:43-07:00
by Wonkey Donkey
Not quite. I'm looking to offset the images all a "small" amount in different directions from the centre point of the base image. It should look like the images are all in a single pile, but not all sharing the same centre point. I'll have a look through that page and see if I can understand how it is working and translate it to my code.

Re: Offset Stacked Images

Posted: 2012-03-03T16:00:28-07:00
by fmw42
see -mosaic or -layers merge using -page to offset your images. -mosaic will expand your result to cover all the offset and not crop the base image.

http://www.imagemagick.org/Usage/layers/#mosaic
http://www.imagemagick.org/Usage/layers/#merge

try this

convert -page +0+0 rose: -page +10+10 rose: -page +20+20 rose: -background none -mosaic 1layer.png

Re: Offset Stacked Images

Posted: 2012-03-04T04:58:48-07:00
by anthony
The 'layer offset' or virtual canvas offset, or simply virtual offset, can be adjusted using the -repage option with a '!' flag. See Repage Image Meta-data
http://www.imagemagick.org/Usage/basics/#page

You may need to clone images into parenthesis before doing this is you want different offsets.

Note you can also change offsets using -set page which can allow you to use a mathematical formula to calculate an offset. It is a bit like Animated Distorts,
http://www.imagemagick.org/Usage/anim_mods/#distort
or how the 'delay' was modified in the third example of Color Morphing
http://www.imagemagick.org/Usage/anim_mods/#morph
but just changing the 'page' offset instead.