Skip to content

Instantly share code, notes, and snippets.

@amutake
Last active December 4, 2016 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amutake/c1b77bd19a19cd6982b911d4a88df6fe to your computer and use it in GitHub Desktop.
Save amutake/c1b77bd19a19cd6982b911d4a88df6fe to your computer and use it in GitHub Desktop.
A script for making 'focal length - number' graph
#!/usr/bin/env bash
FOCAL=focal.dat
WC=~/tmp/wc.rb
if [[ "$1" == "-t" && ! -z "$2" ]]; then
exiftool -T -focallengthin35mmformat *.JPG | grep -v '-' | awk '{print NR, $0}' > $FOCAL
gnuplot -p -e "set terminal png; set term png size 2000,500; set term png font 'ヒラギノ丸ゴ ProN W4, 16'; set output '$2'; set xlabel 'n枚目'; set ylabel '焦点距離'; plot '$FOCAL' using 1:2:(1) with boxes"
rm $FOCAL
open $2
elif [[ "$1" == "-c" && ! -z "$2" ]]; then
exiftool -T -focallengthin35mmformat *.JPG | grep -v '-' | awk '{print $1}' | $WC > $FOCAL
gnuplot -p -e "set terminal png; set output '$2'; set term png font 'ヒラギノ丸ゴ ProN W4, 12'; set xlabel '焦点距離'; set ylabel '枚数'; plot '$FOCAL' using 1:2:(1) with boxes"
rm $FOCAL
open $2
else
echo "Usage: focal.sh (-c|-t) PLOTFILE"
fi
#!/usr/bin/env ruby
wc = {}
while w = gets
w = w.to_i
wc[w] = if wc[w] then wc[w] + 1 else 1 end
end
wc.sort_by do |kv|
kv[0]
end.each do |kv|
puts "#{kv[0]}\t#{kv[1]}"
end
@amutake
Copy link
Author

amutake commented Dec 4, 2016

wc.rb いらなくて、sort -n | uniq -c でいい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment