Yes I am back..
Fred:
+polaroid is an argument-less form of
-polaroid that uses a random angle.
Pooco: -size is only used to speed up JPEG reading. Read the top part on the Montage examples page, or the JPEG file format examples.
Pooco: Montage will NEVER do overlaping images. Period.
It is a simple wrapped around a convert command that starts its work wned all the images have been loaded, and creates an multi-image arrays of the given images. That is all.
For overlapping the better idea is to use the techniques in IM Examples, Layers of multiple images.
http://imagemagick.org/Usage/layers/
As you probably don't know the final size of the resulting image I would suggest you use -mosaic rather than
-flatten. Mosaic creates an expanding canvas for the image, so you only need to position each image by that images top left corner. However all positions must be positive, so may require special handling of the first image, or trimming of the canvas at the end. Not a good way to do things.
Better still you can use the newer
-layers merge, so you don't have to try to keep all positions positive, on the 'virtual canvas'. That is the canvas will grow both in positive and negative directions, and you don't then need to 'guess' or generate an over large canvas as 'bonzo' does in his PHP script. This however will only be available in the newest IM versions.
OKAY. you will need an external loop to figure out the positions of each images top left corner.
Hmmm lets assume you want each rotated (polaroid) image positioned so that images 'center' is a fixed distance from the other images, and you have a directory of image. You also want to overlay each photo to the left of the previous photo.
Lets position the center of the first image at 0,0, and the next image at 100 pixels to the left. As these positions would be centers, we need to subtract half the images size from the postition.
we can loop and work on each individual image, then pipe it as a 'concatenated' MIFF image file format into a pipeline to the 'layering' command that will merge all the images onto the final canvas.
So here is a shell script...
Code: Select all
center=0 # current center location for the next image
offset=100 # distance to the next images center.
background=LightSteelBlue # background canvas color
for image in *_orig.jpg
do
# read, thumbnail, polaroid image to a temp file.
# I used super-sampled polariod to make the result better
# This could have been done in a previous step to this loop
convert -size 500x500 "$image" -thumbnail 240x240 \
-set caption '%t' -bordercolor Lavender -background black \
-pointsize 12 -density 96x96 +polaroid -resize 50% \
/tmp/polaroid_series.png
# Now gather image size, half it, and determine its virtual canvas
# location so as to place it's center at the current position.
xpos=`convert "$tmpfile" -format "%[fx: $center - w/2 ]" info:`
ypos=`convert "$tmpfile" -format "%[fx: - h/2 ]" info:`
# $ypos is always negative
# but $xpos may be positive, in which case it needs to have a '+' sign
xpos=`echo "+$xpos" | sed 's/+-/-/'`
# Output the image into the pipeline for placement on canvas
# at the position (for top-left corner) calculated
convert -page $xpos$ypos "$tmpfile" MIFF:-
# increment position for next image (lets use IM for the math ;-)
center=`convert xc: -format "%[fx: $center + $offset ]" info:`
done |
# Now we read the pipeline of the images output from the above loop
# and create the canvas. Repage the virtual canvas, add some extra
# border space and output it.
convert -background "$background" MIFF:- \
-layers merge +repage \
-bordercolor "$background" -border 5x5 result.jpg
Enjoy!
I have added the above into a script, which will appear at
http://imagemagick.org/Usage/scripts/polariod_series
in a day or two. I don't like its output handling, and will try to fix that up later.
I love the output!!!!
I have to write this up in 'Layering Images' as a practical example.
As the individual images are handled seperatally, due to the need to extract and calcualte positions, you can also do other things, like use a more ordered polariod rotation control.
also as you have total control over placement you can place the first image at 0,0, but the next on the right, then on the left, then on the right, and so on. Then by adding an appropriate -compose method for the the -
layers merge, you can make the first (center) image on top!
What can you come up with!