Scripts

Composite with Watermark Module

#!/bin/bash
cd ~/
ls -t .config/darktable/watermarks/tmp* |grep -v svg |head -n1 |read file
inkscape -f "$file" -l '.config/darktable/watermarks/tmp.svg'
ls -l '.config/darktable/watermarks/tmp.svg' |cut -d' ' -f5 |read size_n
ls -lh '.config/darktable/watermarks/tmp.svg' |cut -d' ' -f5 |read size_h
[ $size_n -gt 9500000 ] && echo "File too large. Size $size_h, but needs to be smaller than 9M." || echo "File size okay $size_h"
ls -t .config/darktable/watermarks/tmp* |grep -v svg |while read file; do
  rm "$file"
done

My script to build basecurves (make sure Darktable isn’t running when you run this)

#!/bin/zsh
rm iso_model_* basecurve.dat basecurve.fit.dat basecurve.sh dt-curve-tool.bin tonecurve.dat tonecurve.fit.dat
ls |grep -i jpg |head -n1 |cut -d'.' -f1 |read file
ls "$file".* |grep -iv jpg |grep -iv xmp |head -n1 |cut -d'.' -f2 |read ext
ls *.$ext |while read file; do
  exiftool "$file" |grep -i iso |head -n1 |awk -F': ' '{print $2}' |read iso
  exiftool "$file" |grep -i model |head -n1 |awk -F': ' '{print $2}' |read model
  echo $file $iso $model >>iso_model_db
done
cat iso_model_db |cut -d' ' -f2- |sort |uniq >iso_model_combinations
cat iso_model_combinations |while read combo; do
  echo $combo |cut -d' ' -f1 |read iso
  echo $combo |cut -d' ' -f2- |read model
  grep " $combo" iso_model_db |cut -d' ' -f1 |while read file; do
    dt-curve-tool-helper "$file"
    last="$file"
  done
  dt-curve-tool -z -e $last -n6 |sed -e "s/$model/$model ($iso)/g" >basecurve.sh
  sh ./basecurve.sh
  rm basecurve.dat basecurve.fit.dat basecurve.sh dt-curve-tool.bin tonecurve.dat tonecurve.fit.dat
done

Monitor Calibration

#!/bin/zsh

dispwin -c
dispcal -v -m -H -y l -q l -t 6500 -b 80 -g 2.2 web
targen -v -d 3 -G -f 128 web
dispread -v -N -H -y l -k web.cal web
colprof -v -D "web" -C "Harry Durgin Photography" -q m -a G -n c web

dispwin -c
dispcal -v -m -H -y l -q l -t 5500 -b 80 -g 2.2 print
targen -v -d 3 -G -f 128 print
dispread -v -N -H -y l -k print.cal print
colprof -v -D "print" -C "Harry Durgin Photography" -q m -a G -n c print

Focus Stack

#!/bin/zsh

rm a_*
ls *.tif |head -n1 |cut -d'.' -f1 |read first
align_image_stack -m -g11 -f 100 -a a_ *.tif
enfuse-mp -o $first'_fused.tif' --exposure-weight=0 --saturation-weight=0 --contrast-weight=1 --hard-mask a_*.tif
convert a_*.tif -average $first'_avg.tif'
convert `ls a_*.tif` -evaluate-sequence mean -quality 100% $first'_mean.tif'

HDR Stack

#!/bin/zsh

rm a_*
mkdir results &> /dev/null
ls *.tif |head -n1 |cut -d'.' -f1 |read file

echo -n 'focal length (24mm): '; read focal_length; focal_length=`echo $focal_length |cut -d'm' -f1`

if [[ -z $focal_length ]]; then
  lens=24
else
  if [ $width -gt $height ]; then
    echo "a(36/($focal_length*2))/3.14*360" |bc -l |cut -d'.' -f1 |read lens
  else
    echo "a(24/($focal_length*2))/3.14*360" |bc -l |cut -d'.' -f1 |read lens
  fi
fi

align_image_stack -g9 -m -f $lens -a a_ *.tif &>/dev/null
enfuse-mp -o results/focus.tif --exposure-weight=0 --contrast-weight=1 --saturation-weight=0 a_*.tif &> /dev/null
enfuse-mp -o results/hdr.tif --exposure-weight=1 --entropy-weight=0 --saturation-weight=0 a_*.tif &> /dev/null
enfuse-mp -o results/luma.tif --exposure-weight=0 --entropy-weight=0 --saturation-weight=1 a_*.tif &> /dev/null
convert `ls a_*.tif` -evaluate-sequence mean -quality 100% results/mean.tif
rm a_*.tif
cd results
convert 
  focus.tif 
  focus.tif 
  hdr.tif 
  hdr.tif 
  luma.tif 
  mean.tif 
  -average $file'_result_mean.tif'
convert 
  focus.tif 
  focus.tif 
  hdr.tif 
  hdr.tif 
  luma.tif 
  -average $file'_result.tif'

get_images.zsh

#!/bin/zsh

url='http://www.esrl.noaa.gov/gmd/webdata/mlo/webcam/northcam.jpg'
xmp='maunaloa/maunaloa.xmp'
dir='maunaloa'

TZ='HST' date |read time
TZ='HST' date +%s |read seconds

# DOWNLOAD WEBCAM IMAGE
wget -T6 --random-wait -O /tmp/image.jpg "$url"

# PROCESS WITH DARKTABLE
rm /tmp/image_dt*
/opt/darktable/bin/darktable-cli /tmp/image.jpg "$xmp" --width 1920 --height 1080 --upscale true /tmp/image_dt.jpg

# ARCHIVE WITH DATE STAMP
convert /tmp/image_dt.jpg -pointsize 36 -fill "#FFFFFF" -draw "text 1400,1050 '$time'" ~/$dir/$seconds.jpg

make_movie.zsh

#!/bin/zsh

num_images=2000
slow=8
frame_window=16
source_dir='/home/harry/int/maunaloa'
mkdir final &> /dev/null
cat /dev/null >frames

# COPY FILES
ls "$source_dir" |tail -n $num_images |while read file; do
  cp "$source_dir/$file" ./
done

# DEFLICKER
/home/harry/bin/timelapse-deflicker.pl -w 15 -p 2

# BUILD FRAME LIST
ls Deflickered |while read file; do
  seq 1 $slow |while read i; do
    echo Deflickered/$file >>frames
  done
done

wc -l frames |cut -d' ' -f1 |read num_frames
typeset -Z6 c

# CREATE FRAMES
seq 1 $num_frames |while read c; do
  convert `head -n $frame_window frames` -average final/$c.jpg
  sed -i '1d' frames
  echo -ne "e[0Kr$c / $num_frames"
done

# MAKE MOVIE
avconv -f image2 -r 30 -i final/%06d.jpg -aspect 16:9 -b:v 15000k -y video.avi &> /dev/null

timelapse-deflicker.pl (by Vangelis Tasoulas)