A script that writes captions under images.

From: Dave Kelly (daveekelly_at_earthlink.net)
Date: 11/27/04


Date: Sat, 27 Nov 2004 02:32:08 GMT


#!/bin/bash
#ALL command line parameters ARE required
#Enclose anything that is more than one word in quotes - "text text"

words=$1 #text to go under the picture
bground=$2 #back ground color of the text part
fground=$3 #fore ground color of the text part - color of text
wide=$4 #resizes the width of the image
save_name=$5 #name to save image under
fontstyle=$6 #font style - use path if somewhere weird
fontsize=$7 #font size in points
image_to_use=$8 #original image name to write the caption for

#A command line might look like this.
#./captions "Now is the time for all good men to go fishing and use a
most excellent
#Mustad Salmon Mooching Hook." white gray 160 fishhook Courier 17
dsc01278.jpg

convert -background "$bground" -fill "$fground" -font "$fontstyle"
-pointsize "$fontsize" \
             -size "$wide"x caption:"$words" \
             temp_text.jpg

convert -size "$wide"x "$image_to_use" -resize "$wide"x image_temp.jpg

convert -append image_temp.jpg temp_text.jpg "$save_name".jpg

rm image_temp.jpg temp_text.jpg

#Credits are in order: Anthony Thyssen,
# <A.Thyssen@griffith.edu.au>
# http://www.cit.gu.edu.au/~anthony/graphics/imagick6/
#for his most excellent tutoral on ImageMagick
#Dave Kelly -- Nov. 2004



Relevant Pages