now working and tested...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-28 03:48:16 +04:00
parent d0d07c852e
commit 84434e8eb6

View File

@ -9,7 +9,10 @@ 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 need to also copy jpg originals to the preview dir (things that
# were shot in jpeg in-camera)...
# XXX do we need to rotate the images using exif data here???
# XXX need to prevent overwriting of unchanged exif data...
# when file exists??
@ -23,26 +26,29 @@ exiftool -if '$jpgfromraw' -b -jpgfromraw -w "$PREVIEW_NAME" \
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
# makepreview SIZE IN OUT
makepreview(){
SIZE="$1"
IN="$2"
OUT="$3"
# create preview dir if it does not already exist...
D="`dirname \"${f/hi-res\ /preview }\"`"
if ! [ -e "$D" ] ; then
mkdir -p "$D"
DIR="`dirname \"${OUT}\"`"
if ! [ -e "$DIR" ] ; then
mkdir -p "$DIR"
fi
# create previews...
if ! [ -e "${f/hi-res\ /preview }" ] ; then
if ! [ -e "${OUT}" ] ; then
# get source size...
W=$(vips im_header_int width "$f")
H=$(vips im_header_int height "$f")
W=$(vips im_header_int width "$IN")
H=$(vips im_header_int height "$IN")
# NOTE: vips appends nasty unprintable \r's to values, so we need to clean them out...
W=${W//[![:digit:]]/}
@ -51,9 +57,18 @@ for f in "${ARCHIVE_ROOT}"/DCIM/hi-res\ \(RAW\)/*jpg ; do
# 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}"
echo "($FACTOR): ${OUT}:${COMPRESSION}"
vips im_shrink "$f" "${f/hi-res\ /preview }:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null
vips im_shrink "$IN" "${OUT}:${COMPRESSION}" $FACTOR $FACTOR 2> /dev/null
fi
}
# XXX use find...
for FROM in "${ARCHIVE_ROOT}"/DCIM/hi-res\ \(RAW\)/*jpg ; do
TO="${FROM/hi-res\ /preview }"
# XXX do different-sized previews...
makepreview "$SIZE" "$FROM" "$TO"
done