From f590f4f54f9b2768206c2a316c6cd91c1896dbeb Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 28 Jun 2013 00:14:48 +0400 Subject: [PATCH] added the current-gen archive structure generator: scripts/process-archive.sh Signed-off-by: Alex A. Naanou --- scripts/process-archive.sh | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 scripts/process-archive.sh diff --git a/scripts/process-archive.sh b/scripts/process-archive.sh new file mode 100755 index 00000000..5dd026b5 --- /dev/null +++ b/scripts/process-archive.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +ARCHIVE_ROOT="./20130501Y.001 - can be sfely deleted (2)" + + +METADATA_DIR="metadata" +RAW_PREVIEW_DIR="hi-res (RAW)" + +PREVIEW_NAME="%-:1d/${RAW_PREVIEW_DIR}/%f.jpg" +JSON_NAME="%-:1d/${METADATA_DIR}/%f.json" + +# XXX need to also copy jpg originals to the preview dir... +# XXX do we need to rotate the images using exif data here??? +# XXX need to prevent overwriting of unchanged exif data... +# when file exists?? + +exiftool -if '$jpgfromraw' -b -jpgfromraw -w "$PREVIEW_NAME" \ + -execute -if '$previewimage' -b -previewimage -w "$PREVIEW_NAME" \ + -execute -tagsfromfile @ -srcfile "$PREVIEW_NAME" -overwrite_original \ + -execute -j -w "$JSON_NAME" \ + -common_args --ext jpg -r "$ARCHIVE_ROOT" -progress + + +# need to calculate this correctly... +FACTOR=4.76 + +SIZE=900 + +ALGORITHM=bicubic + +COMPRESSION=90 + +PATH=$PATH:`pwd`/vips-dev-7.32.0/bin/ + + +# XXX use find... +for f in "${ARCHIVE_ROOT}"/DCIM/hi-res\ \(RAW\)/*jpg ; do + # create preview dir if it does not already exist... + D="`dirname \"${f/hi-res\ /preview }\"`" + if ! [ -e "$D" ] ; then + mkdir -p "$D" + fi + + # calculate the factor... + W=$(vips im_header_string width "$f") + H=$(vips im_header_string height "$f") + + # NOTE: vips appends \r to these!!! + W=${W//[![:digit:]]/} + H=${H//[![:digit:]]/} + + FACTOR=$(echo "scale = 4; if($H > $W) s = $H else s = $W ; s / $SIZE" | bc -l) + + echo "($FACTOR): ${f/hi-res\ /preview }:${COMPRESSION}" + + # create previews... + if ! [ -e "${f/hi-res\ /preview }" ] ; then + vips im_shrink "$f" "${f/hi-res\ /preview }:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null + fi +done +