#!/usr/bin/awk -f # # ensure-rot -- insert rotation into makehtmlgallery list if missing # # usage: ensure-rot srcdir="200-*-nc_d3" < pics.list > pics.rot # # http://www.heikopurnhagen.net/software/ensure-rot # # This program is available under the terms of the GNU General Public # License (GPL). All usual disclaimers apply! # # Heiko Purnhagen (mail@heikopurnhagen.net) # HP 20080811 # HP 20090316 "insert" instead of "append" to be compatible with # captions/textcomments in pics.list, note that all space # is converted to single blanks if orientation is inserted # HP 20101030 use exiftool instead of jhead BEGIN { srcdir = "."; split("0 0 180 0 0 90 0 270",oriar); } { if ((NF >= 2) && (($2 == "0") || ($2 == "90") || ($2 == "180") || ($2 == "270"))) { print $0; } else { sori = ""; getori = "exiftool -s -s -s -Orientation -n " srcdir "/" $1; getori | getline sori; close(getori); if (sori == "-") { pori = "0"; } else { pori = oriar[sori]; } $1 = $1 " " pori; print $0; } } #--