From 0821b527c4e6695c81fe16e6fb42a4c34c15aeae Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 26 Jun 2013 18:07:07 +0400 Subject: [PATCH] working on workflow support scripts... Signed-off-by: Alex A. Naanou --- buildcache.py | 20 +++++++++--------- scripts/extract-metadata.sh | 9 ++++++++ scripts/vips-tn.sh | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100755 scripts/extract-metadata.sh create mode 100755 scripts/vips-tn.sh diff --git a/buildcache.py b/buildcache.py index be0ff3ae..ea684adc 100755 --- a/buildcache.py +++ b/buildcache.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20130622165505''' +__sub_version__ = '''20130626175935''' __copyright__ = '''(c) Alex A. Naanou 2011''' @@ -63,8 +63,8 @@ CONFIG = { '150px': 150, '350px': 350, '900px': 900, - '1080px': 1080, - '1920px': 1920, +## '1080px': 1080, +## '1920px': 1920, } } @@ -316,7 +316,8 @@ def build_previews(image, path=None, config=CONFIG, dry_run=True, verbosity=0): img_path = image['path'] if absolute_path == False: - source_path = os.path.join(path, img_path) +## source_path = os.path.join(path, img_path) + source_path = os.path.join(path, urllib2.url2pathname(img_path)) else: # XXX is this the best way??? o = urllib2.urlopen(img_path) @@ -348,16 +349,15 @@ def build_previews(image, path=None, config=CONFIG, dry_run=True, verbosity=0): # add image to index... if not os.path.exists(p): - # use the preview to speed things up... - # NOTE: this will degrade the quality of previews after - # several resizes... -## if preview != None: -## img = preview scale = spec/float(max(*img.size)) preview = img.resize((int(img.size[0]*scale), int(img.size[1]*scale)), Image.ANTIALIAS) if not dry_run: - preview.save(p) + preview.save(p, quality=80) + # use the preview to speed things up... + # NOTE: this will degrade the quality of previews after + # several resizes... + img = Image.open(p, 'r') else: preview.close() diff --git a/scripts/extract-metadata.sh b/scripts/extract-metadata.sh new file mode 100755 index 00000000..793aad7c --- /dev/null +++ b/scripts/extract-metadata.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# extract hi-res previews... +#exiftool -b -JpgFromRaw -w "%-:1d/hi-res (RAW)/%f.jpg" -ext NEF -r . + + +# extract metadata in JSON format... +exiftool -j -w "%-:1d/metadata/%f.json" -ext NEF -r . -progress + diff --git a/scripts/vips-tn.sh b/scripts/vips-tn.sh new file mode 100755 index 00000000..7a75af60 --- /dev/null +++ b/scripts/vips-tn.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SCALE=0.21 +FACTOR=4.76 +ALGORITHM=bicubic + +COMPRESSION=90 + +PATH=$PATH:`pwd`/vips-dev-7.32.0/bin/ + +for f in */DCIM/hi-res\ \(RAW\)/*jpg ; do + # this yields images with EXTREAM aliasing artifacts, with all supported algorithms + # NOTE: vips appears not to support lanczos scaling... + ##vips im_affinei_all "$f" "${f/hi-res\ /preview }:${COMPRESSION}" $ALGORITHM $SCALE 0 0 $SCALE 0 0 + + # NOTE: -n (no sharpening) gives a bit too blurry results... + # NOTE: this also renames the files... + ##vipsthumbnail -s 900 "$f" + + # this gives lots of warnings but appears to be OK... but not too fast. + # so far, this is the best result... + # NOTE: this, being "not too fast" actually is the fastest when comparing to I_View or PIL... + # - I_View ~2-3 minutes + # - PIL ~6 minutes + # - im_shrink <2 minutes + vips im_shrink "$f" "${f/hi-res\ /preview }:${COMPRESSION}" $FACTOR $FACTOR + + # this is different in that it uses a shrink factor while opening the image, thus + # a different scale factor... + # - ALLOT faster + # - blurry in comparison + ##vips im_shrink "$f:4" "${f/hi-res\ /preview }:${COMPRESSION}" 1.19 1.19 + + # apply different amounts of read scaling... + # still quite extreme aliasing... + # IDEA: it's so extream, might be a good idea to first blur the image some and then scale... + ##vips im_affinei_all "$f:2" "${f/hi-res\ /preview }:${COMPRESSION}" $ALGORITHM 0.42 0 0 0.42 0 0 + # artifacts, better than all previous attempts at im_affinei_all, but worse than plain im_shrink... + ##vips im_affinei_all "$f:4" "${f/hi-res\ /preview }:${COMPRESSION}" $ALGORITHM 0.84 0 0 0.84 0 0 +done +