diff --git a/scripts/process-archive.sh b/scripts/process-archive.sh index 5dd026b5..af9db9d7 100755 --- a/scripts/process-archive.sh +++ b/scripts/process-archive.sh @@ -21,9 +21,6 @@ exiftool -if '$jpgfromraw' -b -jpgfromraw -w "$PREVIEW_NAME" \ -common_args --ext jpg -r "$ARCHIVE_ROOT" -progress -# need to calculate this correctly... -FACTOR=4.76 - SIZE=900 ALGORITHM=bicubic @@ -32,7 +29,6 @@ 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... @@ -41,20 +37,22 @@ for f in "${ARCHIVE_ROOT}"/DCIM/hi-res\ \(RAW\)/*jpg ; do 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 + + # get source size... + W=$(vips im_header_int width "$f") + H=$(vips im_header_int height "$f") + + # NOTE: vips appends nasty unprintable \r's to values, so we need to clean them out... + W=${W//[![:digit:]]/} + H=${H//[![:digit:]]/} + + # calculate the factor... + FACTOR=$(echo "scale = 4; if($H > $W) s = $H else s = $W ; s / $SIZE" | bc -l) + + echo "($FACTOR): ${f/hi-res\ /preview }:${COMPRESSION}" + vips im_shrink "$f" "${f/hi-res\ /preview }:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null fi done