#!/bin/bash - #=============================================================================== # # FILE: exif.sh # # USAGE: ./exif.sh -o objektiv [-l ohnisko] [-f clona] fotka.[jpg|cr2|..] fotka2.[jpg|cr2|..] # # DESCRIPTION: Nastavi nektera EXIF data u fotek porizenych manualnimi objektivy # # OPTIONS: -o jeden ze znamych objektivu s parametry definovanymi nize # -l pouzite ohnisko (u zoom objektivu se da definovat Lmin, Lmax # a timhle parametrem pak specifikovat na jakem ohnisku se vlastne fotilo). # Pokud se nezada, pouzije se Lmax # -f pouzita clona. Pokud se nezada, predpoklada se foceni na plnou diru. # # REQUIREMENTS: exiv2 # BUGS: --- # NOTES: --- # AUTHOR: Ota Zimmermann (zLOST) # CREATED: 26/02/18 13:21:36 CET # REVISION: --- #=============================================================================== set -o nounset # Treat unset variables as an error function howto { echo "./exif.sh -o [trioplan50|helios|industar61|samyang85|industar50|tessar50|telemegor180|pentacon29] [-l ohnisko] [-f pouzita clona] fotka.[jpg|cr2|...]" } Make="" # vyrobce objektivu Lmin="" # kratke ohnisko Lmax="" # dlouhe ohnisko (default) Fmax="" # svetelnost pri maximalne otevrene clone (plna dira) Fmin="" # svetelnost pri zavrene clone Fnumber="" # clona pouzita behem foceni (== Fmax) FminL="" # svetelnost na kratkym konci FmaxL="" # svetelnost na dlouhym konci (== Fmax) Length="" # pouzite ohnisko (== Lmax) Lens="" while getopts "o:l:f:" opt; do case ${opt} in o) Lens=${OPTARG} ;; l) Length=${OPTARG} ;; f) Fnumber=${OPTARG} ;; esac done if [ x${Lens} == "x" ]; then echo "Typ objektivu (parametr -o) je povinny..." howto exit fi case ${Lens} in trioplan50) Make="Meyer-Optik Görlitz" Model="Trioplan 50mm f/2.9" #Lmin="" Lmax="50" SN="2224344" Fmax="2.9" Fmin="22" ;; helios) Make="Helios" Model="44-2 58mm f/2" Lmax="58" Fmax="2" Fmin="16" SN="7765411" ;; industar61) Make="Industar" Model="61 L/Z (MC) 50mm f/2.8 " Lmax="50" Fmax="2.8" Fmin="16" SN="8707286" ;; samyang85) Make="Samyang" Model="85mm f/1.4 Aspherical IF" Lmax="85" Fmax="1.4" Fmin="22" SN="A217D0264" ;; industar50) Make="Industar" Model="50-2 50mm f/3.5" Lmax="50" Fmax="3.5" Fmin="16" SN="7149595" ;; tessar50) Make="Carl Zeiss" Model="Jena DDR Tessar 50mm f/2.8" Lmax="50" Fmax="2.8" Fmin="22" SN="8333263" ;; telemegor180) Make="Meyer-Optik Görlitz" Model="Telemegor 180mm f/5.5" Lmax="180" Fmax="5.5" Fmin="22" SN="1728275" ;; pentacon29) Make="Pentacon" Model="auto 29mm f/2.8" Lmax="29" Fmax="2.8" Fmin="22" SN="6308110" ;; *) echo "Tenhle objektiv neznám..." howto exit; ;; esac shift $((OPTIND-1)) Fotky=$@ if [ "x${Fotky}" == "" ]; then echo "Nemam v cem EXIF nastavit..." howto exit; fi function apex { val=$1 echo "x=100*l(${val}*${val})/l(2); scale=0; x*10/10"|bc -l } function ten { val=$1 echo "scale=0; 1000*${val}/100"|bc -l } function canonRev { #Canon val=$1 ret=$(echo "64*l(${val})/(l(e(1))*l(2))"|bc -l) printf %.0f ${ret} } function focalRev { #Nikon; nedela co ma :( val=$1 #double focal = 5.0 * pow(2.0, value.toLong()/24.0); ret=$(echo "24 * l(${val}/5) / l(2)"|bc -l) printf %.0f ${ret} } if [ x${Fnumber} == "x" ]; then Fnumber=${Fmax}; fi if [ x${FminL} == "x" ]; then FminL=${Fmax}; fi if [ x${FmaxL} == "x" ]; then FmaxL=${Fmax}; fi if [ x${Lmin} == "x" ]; then Lmin=${Lmax}; fi if [ x${Length} == "x" ]; then Length=${Lmax}; fi echo "${Make} ${Model} (F${Fnumber}, Fmin:${Fmin}, Fmax:${Fmax}, Lmin:${Lmin}, Lmax:${Lmax}, Length:${Length})" for fotka in ${Fotky}; do echo " upravuji ${fotka}" exiv2 -M"set Exif.Photo.FNumber $(ten ${Fnumber})/10" \ -M"set Exif.Photo.ApertureValue $(apex ${Fnumber})/100" \ -M"set Exif.Photo.FocalLength ${Length}/1" \ -M"set Exif.Photo.LensMake ${Make}" \ -M"set Exif.Photo.LensModel ${Make} ${Model}" \ -M"set Exif.Photo.LensSerialNumber ${SN}" \ -M"set Exif.Photo.MaxApertureValue F${Fmax}" \ -M"set Exif.Photo.LensSpecification $(ten ${Lmin})/10 $(ten ${Lmax})/10 $(ten ${FminL})/10 $(ten ${FmaxL})/10" \ -M"set Exif.Canon.LensModel ${Make} ${Model}" \ -M"set Exif.Canon.FocalLength 0 ${Lmax} 63343 21770" \ -M"set Exif.CanonCs.Lens ${Lmax} ${Lmin} 1" \ -M"set Exif.CanonCs.LensType 65535" \ -M"set Exif.CanonCs.MaxAperture $(canonRev ${Fmax})" \ -M"set Exif.CanonCs.MinAperture $(canonRev ${Fmin})" \ -M"set Exif.CanonSi.ApertureValue $(canonRev ${Fnumber})" \ -M"set Exif.CanonSi.TargetAperture $(canonRev ${Fnumber})" \ -M"set Exif.NikonLd2.MinFocalLength $(focalRev ${Lmin})" \ -M"set Exif.NikonLd2.MaxFocalLength $(focalRev ${Lmax})" \ -M"set Exif.NikonLd2.FocalLength $(focalRev ${Length})" \ -M"set Exif.Nikon3.Lens $(ten ${Lmin})/10 $(ten ${Lmax})/10 $(ten ${FminL})/10 $(ten ${FmaxL})/10" \ ${fotka} done