mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added exif rotation support to buildcache.py...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
abc967b8c0
commit
26b850d11f
@ -1,7 +1,7 @@
|
||||
#=======================================================================
|
||||
|
||||
__version__ = '''0.0.01'''
|
||||
__sub_version__ = '''20130626175935'''
|
||||
__sub_version__ = '''20130629041032'''
|
||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||
|
||||
|
||||
@ -241,6 +241,8 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, verbosity=0):
|
||||
'''
|
||||
absolute_path = config['absolute-path']
|
||||
|
||||
orientation = None
|
||||
|
||||
for name in os.listdir(path):
|
||||
fname, ext = os.path.splitext(name)
|
||||
ext = ext[1:]
|
||||
@ -251,6 +253,7 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, verbosity=0):
|
||||
source_path = pathjoin(path, name)
|
||||
raw = metadata.ImageMetadata(source_path)
|
||||
raw.read()
|
||||
orientation = raw['Exif.Image.Orientation']
|
||||
##!!! can there be no previews?
|
||||
# get the biggest preview...
|
||||
preview = raw.previews[0]
|
||||
@ -272,6 +275,12 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, verbosity=0):
|
||||
# normal images...
|
||||
elif ext == IMAGE:
|
||||
source_path = pathjoin(path, name)
|
||||
meta = metadata.ImageMetadata(source_path)
|
||||
meta.read()
|
||||
if 'Exif.Image.Orientation' in meta:
|
||||
orientation = meta['Exif.Image.Orientation'].value
|
||||
else:
|
||||
orientation = 0
|
||||
|
||||
# skip other files...
|
||||
else:
|
||||
@ -282,6 +291,26 @@ def build_images(path, config=CONFIG, gid_generator=hash_gid, verbosity=0):
|
||||
'name': name,
|
||||
'type': 'image',
|
||||
'state': 'single',
|
||||
'orientation': {
|
||||
1: 0,
|
||||
2: 0,
|
||||
3: 180,
|
||||
4: 0,
|
||||
5: 90,
|
||||
6: 90,
|
||||
7: 90,
|
||||
8: 270,
|
||||
}[orientation],
|
||||
'flipped': {
|
||||
1: None,
|
||||
2: ['horizontal'],
|
||||
3: None,
|
||||
4: ['vertical'],
|
||||
5: ['vertical'],
|
||||
6: None,
|
||||
7: ['horizontal'],
|
||||
8: None,
|
||||
}[orientation],
|
||||
'path': getpath(path, source_path, absolute_path),
|
||||
'ctime': os.path.getctime(pathjoin(path, name)),
|
||||
'preview': {},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARCHIVE_ROOT="./20130501Y.001 - can be sfely deleted (2)"
|
||||
ARCHIVE_ROOT="."
|
||||
|
||||
|
||||
METADATA_DIR="metadata"
|
||||
@ -12,6 +12,11 @@ PREVIEW_NAME="%-:1d/${RAW_PREVIEW_DIR}/%f.jpg"
|
||||
JSON_NAME="%-:1d/${METADATA_DIR}/%f.json"
|
||||
|
||||
|
||||
# TODO do a version of this using exiv2...
|
||||
# - to be more flexible...
|
||||
# - check speed...
|
||||
# - give the user more options...
|
||||
#
|
||||
|
||||
# XXX need to also copy jpg originals to the preview dir (things that
|
||||
# were shot in jpeg in-camera)...
|
||||
@ -19,12 +24,14 @@ JSON_NAME="%-:1d/${METADATA_DIR}/%f.json"
|
||||
# XXX need to prevent overwriting of unchanged exif data...
|
||||
# when file exists??
|
||||
# XXX add PSD metadata extraction...
|
||||
# -execute '-FileModifyDate<DateTimeOriginal' -tagsfromfile @ \
|
||||
# -srcfile "$PROCESSED_PREVIEW_NAME" -overwrite_original \
|
||||
# XXX keep file dates...
|
||||
|
||||
exiftool -if '$jpgfromraw' -b -jpgfromraw -w "$PREVIEW_NAME" \
|
||||
-execute -if '$previewimage' -b -previewimage -w "$PREVIEW_NAME" \
|
||||
-execute '-FileModifyDate<DateTimeOriginal' -tagsfromfile @ -srcfile "$PREVIEW_NAME" -overwrite_original \
|
||||
-execute '-FileModifyDate<DateTimeOriginal' -tagsfromfile @ -srcfile "$PROCESSED_PREVIEW_NAME" -overwrite_original \
|
||||
-execute '-FileModifyDate<DateTimeOriginal' -tagsfromfile @ \
|
||||
-srcfile "$PREVIEW_NAME" -overwrite_original \
|
||||
-execute -j -w "$JSON_NAME" \
|
||||
-common_args --ext jpg -r "$ARCHIVE_ROOT" -progress
|
||||
|
||||
@ -33,7 +40,7 @@ SIZE=900
|
||||
|
||||
COMPRESSION=90
|
||||
|
||||
PATH=$PATH:`pwd`/vips-dev-7.32.0/bin/
|
||||
PATH=$PATH:/mnt/d/Program\ Files/vips/bin/
|
||||
|
||||
# makepreview SIZE IN OUT
|
||||
makepreview(){
|
||||
@ -70,10 +77,14 @@ makepreview(){
|
||||
|
||||
|
||||
# XXX use find...
|
||||
for FROM in "${ARCHIVE_ROOT}"/DCIM/hi-res\ \(RAW\)/*jpg ; do
|
||||
|
||||
cd "${ARCHIVE_ROOT}"
|
||||
|
||||
for FROM in */DCIM/hi-res\ \(RAW\)/*jpg ; do
|
||||
TO="${FROM/hi-res\ /preview }"
|
||||
|
||||
# XXX do different-sized previews...
|
||||
makepreview "$SIZE" "$FROM" "$TO"
|
||||
makepreview "$SIZE" "./$FROM" "$TO"
|
||||
done
|
||||
|
||||
# vim:set nowrap nospell :
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user