Re: horizontal stack of polaroids?
Posted: 2008-05-09T00:18:31-07:00
modification of above, this one grabs the most recent 5 jpgs from a file tree of any depth
you had a small bug in your script-- tmpfile needs to be set at top and added to end of first convert line
if i have time i'll do what i said in the previous message soon.
you had a small bug in your script-- tmpfile needs to be set at top and added to end of first convert line
if i have time i'll do what i said in the previous message soon.
Code: Select all
#!/bin/sh
numberofimages=5 # number of recent images to grab
center=0 # current center location for the next image
offset=100 # distance to the next images center.
tmpfile=/tmp/polaroids.png # temporary file
outfile=result.png # finished file
background=transparent # background canvas color
# Grab the newest 5 jpgs from your file tree
files=`ls -altr \`find . -name '*.jpg' -type f -print\` | grep -v $outfile | tai
l -$numberofimages | awk '{ print $8 }'`;
echo "Processing images: " $files;
for image in $files
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 snow -background black \
-pointsize 12 -density 96x96 +polaroid -resize 50% \
$tmpfile
# 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 $outfile