To create the calender-page I used the followin script, which creates the ImageMagick "convert"-command. The picture is created with following command:

convert 2009 1 bild.jpg | sh

calendar 2009 1 bild.jpg | sh

First parameter is the year, second the month with January = 1 and the third is the name of the picture.

If you call only "calendar 2009 1 bild.jpg" the script will type the convert command with all parameters on stdout.


Save the following script as calendar. Make it executable with "chmod u+x calendar". The script will type the "convert"-command with Parameters to stdout, to produce the picture pipe the output to a shell.

PS: Download here http://www.ipernity.com/doc/20310/3694701?from=3694701&at=1229982134

#!/bin/sh

[ $# -lt 3 ] && echo "usage calender YEAR MONTH PICTURE" && exit 1

YEAR=${1}
MONTH=${2}
PICTURE=${3}

# Get width and height of the picture
W=`identify -format "%w" ${PICTURE}`
H=`identify -format "%h" ${PICTURE}`

# Define the number of days in a mmonth
DINM=(31 28 31 30 31 30 31 31 30 31 30 31)
# Define the names ot the days
NOFD=(So Mo Di Mi Do Fr Sa)
NOFM=(Januar Februar März April Mai Juni Juli August September Oktober November Dezember)

PREFIX="ip"
FONT="Andy MT"
PTSIZE=$((H/40))
SIGN="© 2008,2009 by Byggvir of Barley"

echo -e "convert \\"
echo -e "-gravity North \\"
echo -e "-pointsize 128 -family \"$FONT\" \\"
echo -e "-fill Black -draw 'text 32,8 \"${NOFM[$((MONTH-1))]} $YEAR\"' \\"
echo -e "-fill Lightgrey -draw 'text 31,7 \"${NOFM[$((MONTH-1))]} $YEAR\"' \\"

echo -e "-gravity SouthEast \\"
echo -e "-pointsize 16 -family \"$FONT\" \\"
echo -e "-fill Black -draw 'text 32,8 \"$SIGN\"' \\"
echo -e "-fill Lightgrey -draw 'text 31,7 \"$SIGN\"' \\"


echo -e "-gravity NorthWest \\"
echo -e "-pointsize $PTSIZE -family \"$FONT\" \\"

for (( d=1 ; d <= DINM[MONTH-1] ; d++ ))
do
  X=$((W*(2*d-1)/2/(DINM[MONTH-1]+1)))
  Y=$((H-3*PTSIZE-5))
  WDAY=${NOFD[`date +%w -d "$YEAR-$MONTH-$d"`]}
  case "$WDAY" in
   So) COLOR=Red ;;
   Sa) COLOR=MediumVioletRed ;;
   * ) COLOR=Lightgrey ;;
  esac
  echo "-fill Black -draw 'text $X,$Y \"$WDAY\"' \\"
  echo "-fill $COLOR -draw " "'text $(($X-1)),$(($Y-1)) \"$WDAY\"' \\"
  Y=$((H-2*PTSIZE))
  echo "-fill Black -draw 'text $X,$Y \"$d\"' \\"
  echo "-fill $COLOR -draw 'text $(($X-1)),$(($Y-1)) \"$d\"' \\"
done
echo "${PICTURE} ${PREFIX}-${PICTURE}"