Exif/Exiftool

Aus SchnallIchNet
< Exif(Weitergeleitet von Exiftool)
Wechseln zu: Navigation, Suche

general

Datum extrahieren aus Exif-Daten

exiftool -d '%F %X' -DateTimeOriginal -S -s file.jpg

external exif manipulation script via unixwitch

very useful script i think...
but untested...

base script

#!/bin/bash
 
# exitag
# 2007-02-14 / Hella Breitkopf / www.unixwitch.de
 
# add/delete/show later added exif text like comments, keywords or header
# just for hella's dokuwiki
 
# if you want to use this "as is"
# 1) it's entirely your problem (no guarantee)
# 2) you need to create lots of symlinks pointing all to this script (exitag):
#    kwadd, kwshow, kwdel, titleadd, ... , subtitleadd ..., comadd ...
#    create these in your bin directory:
 
# for TYPE in title subtitle com kw; 
# do echo ; 
# for ACT in add ls del; 
# do echo $TYPE$ACT;
# ln -s exitag $TYPE$ACT; 
# done ; done
 
EXIFTOOL="/usr/bin/exiftool"
EXIFTOOLOPT="-overwrite_original_in_place"
 
programname=`basename $0`
 
function doshowtag
{
    TRENNZEICHEN=";"
    echo '$FileName'$TRENNZEICHEN'$'$TYPE' ' | \
      $EXIFTOOL -p - $1 | \
      grep --binary-files=text $TRENNZEICHEN
    ### grep nach Trennzeichen wg. buggy Anzeige
    ### von "u30D,S410D,u410D" (Camera Model Name) ???
}
 
function dowritetag { $EXIFTOOL $EXIFTOOLOPT -$TYPE="$TAG" $1 ; }
function doaddtag   { $EXIFTOOL $EXIFTOOLOPT -$TYPE+="$TAG" $1 ; }
function dodeltag   { $EXIFTOOL $EXIFTOOLOPT -$TYPE="" $1 ; }
function dosubtag   { $EXIFTOOL $EXIFTOOLOPT -$TYPE-="$TAG" $1 ; }
 
# TYPEMATCH
case $programname in
  titel*|title*)        TYPE='HEADLINE' ;;
  subtitel*|subtitle*)  TYPE='CAPTION-ABSTRACT' ;;
  com*)                 TYPE='COMMENT' ;;
  kw*)                  TYPE='KEYWORDS' ;;
esac
 
# ACTIONMATCH
case $programname in
  *add)
    TAG=$1;shift # read tag-text and go to next option (filename(s))
    while (( "$#" )); do
      if [[ $TYPE == "KEYWORDS" ]]; then
        doaddtag "$1"
      else
        dowritetag "$1"
      fi
      shift
    done
  ;;
  *ls|*show|*list)
    while (( "$#" )); do
      doshowtag "$1"
      shift
    done
  ;;
  *del)
    if [[ $TYPE == "KEYWORDS" ]]; then
      TAG=$1; shift
      while (( "$#" )); do
        dosubtag "$1" ; shift
      done
    else
      while (( "$#" )); do
        dodeltag "$1" ; shift
      done
    fi
  ;;
  exitag|*)
  while  (( "$#" )); do
    TYPE='HEADLINE' ; doshowtag "$1" ;
    TYPE='CAPTION-ABSTRACT' ; doshowtag "$1" ;
    TYPE='COMMENT' ; doshowtag "$1" ;
    TYPE='KEYWORDS' ; doshowtag "$1" ;
    shift
  done
esac

Usage:

kwadd "Test123" '*.jpg'

Adds the keyword 'Test123' to all JPG's in current directory

extension script

#!/bin/bash
# tagging-script mit grafischer Anzeige (xv) und Hellas Exif-Tag-Script
# funktioniert nur in xterm (und konsole und ?)
# Parameter: Pfad zum Bild
# Interaktiv: Abfrage nach neuen Tags
# Hella Breitkopf, 2008-06-15, www.unixwitch.de
 
PIC=$1
KEYWORDS=`kwls $PIC|awk -F';' '{print $2}'`
 
function tagdialog {
   xv -windowid $WINDOWID -geometry 250x250 $PIC &
   XVPID=$!
 
   echo $KEYWORDS
 
   read -p "zusaetzliche keywords (mit komma trennen):" NEUEKEYWORDS
 
   kill -9 $XVPID
 
   echo "neue Keywords: $KEYWORDS, $NEUEKEYWORDS"
 
   kwadd "$NEUEKEYWORDS" $PIC
}

tagdialog

Usage:

xtag bild_2357.jpg