#!/bin/sh USAGE='Usage: brewview [options] Image-file viewing and favorites-file database handling. Depends on qiv (with options -m -t -f -i). Copyright © Daniel Ljunggren . Feb 2008. [options]: -s : Save to database-file (default: favorites.db or stars.db). -f : Show images from .db-files. -e : Show images from and edit the same .db-file (overrides -s). -x : Generate db-file for image-files where Rating metatag is higher than value. ' FAVORITES_FILE="favorites.db" STARS_FILE="stars.db" QIV_PARAM="" QIV_PATH=/usr/bin/qiv strstr() { [ "${1#*$2*}" = "$1" ] && return 1 return 0 } while [ $# -gt 0 ] do case "$1" in -S) QIV_PARAM="${QIV_PARAM} -S" shift 1 ;; -s) FAVORITES_FILE="$2" STARS_FILE="$2" shift 2 ;; -f) shift 1 if [ -e favorites.tmp ] ; then echo "favorites.tmp exist!" 1>&2 exit 2 fi for FILE do DIR=`dirname $FILE`/ if [ $DIR == "./" ] ; then DIR="" fi BASE=`basename $FILE` cat $FILE | while read line ; do DIRLINE=`dirname $line`/ BASELINE=`basename $line` if [ $DIRLINE == "./" ] ; then DIRLINE="" fi echo $DIR$DIRLINE$BASELINE >> favorites.tmp ; done done export FAVORITES_FILE sort favorites.tmp -u -o favorites.tmp ${QIV_PATH} -R -m -t -f -i -e -l -d 12 ${QIV_PARAM} -F favorites.tmp rm favorites.tmp exit 0 ;; -e) shift 1 for FILE do DIR=`dirname $FILE` BASE=`basename $FILE` FAVORITES_FILE=$BASE export FAVORITES_FILE CURRENTDIR=`pwd` cd $DIR ${QIV_PATH} -R -m -t -f -i -e -l -d 12 ${QIV_PARAM} -F $BASE cd $CURRENTDIR done break ;; -x) shift 1 if [ -z $1 ] ; then echo "No images selected..." 1>&2 exit 2 fi LEVEL=1 OPT=$1 if [ $OPT == [digit] ]; then LEVEL=$OPT shift 1 fi if [ -e ${STARS_FILE} ] ; then echo "brewview: Warning: regenerating ${STARS_FILE}. A backup copy is saved to ${STARS_FILE}.bak..." 1>&2 mv -f "${STARS_FILE}" "${STARS_FILE}.bak" rm -f ${STARS_FILE} fi for FILE do #Based on IPTC tag UserComment created in qiv-command. #STARS=`exiftool -UserComment ${FILE} | cut -b35-` #if [ "${STARS}" = "***" ]; then # echo "Adding ${FILE}" # echo ${FILE} >> ${STARS_FILE} ; #fi #Based on IPTC tag 'Urgency' created by digikam. #RATE=`exiftool -Urgency ${FILE} | cut -b35-` RATE=`exiftool -Rating ${FILE} | cut -b35-` if [ ! -z ${RATE} ] && [ ${RATE} -ge ${LEVEL} ]; then echo "Adding ${FILE} with level ${RATE}" echo ${FILE} >> ${STARS_FILE} ; fi done if [ -e ${STARS_FILE} ] ; then sort ${STARS_FILE} -u -o ${STARS_FILE} echo "brewview: ${STARS_FILE} generated; view with 'brewview -f ${STARS_FILE}'" else echo "brewview: ${STARS_FILE} not generated, found no tags marked for images" fi exit 0 ;; -h) echo "$USAGE" 1>&2 exit 2 ;; *) export FAVORITES_FILE ${QIV_PATH} -m -t -f -i -e -l ${QIV_PARAM} $* exit 0 ;; esac done