Offset Stacked Images

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
Wonkey Donkey
Posts: 2
Joined: 2012-03-03T13:50:37-07:00
Authentication code: 8675308

Offset Stacked Images

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Offset Stacked Images

Post by Bonzo »

Are you trying to acheve this effect: layers
Wonkey Donkey
Posts: 2
Joined: 2012-03-03T13:50:37-07:00
Authentication code: 8675308

Re: Offset Stacked Images

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Offset Stacked Images

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Offset Stacked Images

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply