verzia 1.6, 2011/03/21 20:56:18 |
verzia 1.7, 2014/02/05 00:55:53 |
|
|
# acpi - only for laptops |
# acpi - only for laptops |
# |
# |
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk> |
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk> |
# Copyright (c) 2005-2009 Platon Group, http://platon.sk/ |
# Copyright (c) 2005-2014 Platon Group, http://platon.sk/ |
# Licensed under terms of GNU General Public License. |
# Licensed under terms of GNU General Public License. |
# All rights reserved. |
# All rights reserved. |
# |
# |
|
|
# 2006-08-14 - enhanced - images are auto-rotated - Exif tag Exif.Image.Orientation is used |
# 2006-08-14 - enhanced - images are auto-rotated - Exif tag Exif.Image.Orientation is used |
# |
# |
|
|
# $Platon: scripts/shell/photo-managment/foto-copy,v 1.5 2011-03-01 22:31:31 rajo Exp $ |
# $Platon: scripts/shell/photo-managment/foto-copy,v 1.6 2011-03-21 20:56:18 rajo Exp $ |
|
|
# where to mount you memory card - configure in /etc/fstab something like this: |
# where to mount you memory card - configure in /etc/fstab something like this: |
# /dev/sdb1 /foto vfat iocharset=iso8859-2,umask=002,codepage=852,showexec,users,gid=users,noauto,nodev,nosuid,quiet 0 0 |
# /dev/sdb1 /foto vfat iocharset=iso8859-2,umask=002,codepage=852,showexec,users,gid=users,noauto,nodev,nosuid,quiet 0 0 |
MOUNTPOINT="/foto" |
#MOUNTPOINT="/foto" |
|
MOUNTPOINT="/media/usb0" |
# where to copy your photos for sorting - /home/rajo/media/foto/2006/ |
# where to copy your photos for sorting - /home/rajo/media/foto/2006/ |
DEST="$HOME/media/foto/`date +%Y`" |
DEST="$HOME/media/foto/`date +%Y`" |
|
#@DEST="$HOME/tmp/foto-copy-test" |
# wildcard names of your original photos |
# wildcard names of your original photos |
RENAME_FILES="PICT*.JPG pict*.jpg img_*.jpg IMG_*.JPG dsf*.jpg DSC*.JPG dsc*.jpg" |
RENAME_FILES="PICT*.JPG pict*.jpg img_*.jpg IMG_*.JPG dsf*.jpg DSC*.JPG dsc*.jpg" |
# howto rename your files: img_1234.jpg --> 2006-08-13_230001_img_1234.jpg (image taken on 2006-08-13 23:00:01) |
# howto rename your files: img_1234.jpg --> 2006-08-13_230001_img_1234.jpg (image taken on 2006-08-13 23:00:01) |
JHEAD_OPTS="-n%Y-%m-%d_%H%M%S_%f" |
JHEAD_OPTS="-autorot -n%Y-%m-%d_%H%M%S_%f" |
|
|
# paths setup: |
# paths setup: |
JHEAD="jhead" |
JHEAD="jhead" |
Riadok 49 if [ ! -d $DEST ]; then |
|
Riadok 51 if [ ! -d $DEST ]; then |
|
fi |
fi |
cd $DEST |
cd $DEST |
|
|
|
# clean up extensions {{{ |
|
for i in *.JPG *.jpeg *.JPEG *.CRW *.CR2; do |
|
[ "x$i" = "x*.JPG" ] && continue |
|
[ "x$i" = "x*.JPEG" ] && continue |
|
[ "x$i" = "x*.jpeg" ] && continue |
|
[ "x$i" = "x*.CRW" ] && continue |
|
[ "x$i" = "x*.CR2" ] && continue |
|
|
|
if [ "x${i%.JPG}" != "x$i" ]; then # change *.JPG --> *.jpg |
|
mv "$i" "${i%.JPG}.jpg" |
|
fi |
|
if [ "x${i%.JPEG}" != "x$i" ]; then # change *.JPEG --> *.jpg |
|
mv "$i" "${i%.JPEG}.jpg" |
|
fi |
|
if [ "x${i%.jpeg}" != "x$i" ]; then # change *.jpeg --> *.jpg |
|
mv "$i" "${i%.jpeg}.jpg" |
|
fi |
|
if [ "x${i%.CRW}" != "x$i" ]; then # change *.CRW --> *.crw |
|
mv "$i" "${i%.CRW}.crw" |
|
fi |
|
if [ "x${i%.CR2}" != "x$i" ]; then # change *.CR2 --> *.cr2 |
|
mv "$i" "${i%.CR2}.cr2" |
|
fi |
|
done # }}} |
|
|
# lossless rotation of JPEG files |
# lossless rotation of JPEG files |
do_rotation() |
do_rotation() |
{ # {{{ |
{ # {{{ |
|
|
|
|
# now rotate and rename your JPEG files from your CF card |
# now rotate and rename your JPEG files from your CF card |
for ren in $RENAME_FILES; do |
for ren in $RENAME_FILES; do |
rotate_jpeg $DEST/$ren |
[ "x$ren" = "xpict*.jpg" ] && continue |
$JHEAD $JHEAD_OPTS $DEST/$ren | while read jpg arrow newjpg; do |
[ "x$ren" = "xPICT*.JPG" ] && continue |
mv ${jpg%.jpg}.CR2 ${newjpg%.jpg}.CR2 |
[ "x$ren" = "ximg_*.jpg" ] && continue |
done |
[ "x$ren" = "xIMG_*.jpg" ] && continue |
|
[ "x$ren" = "xIMG_*.JPG" ] && continue |
|
[ "x$ren" = "xdsf*.jpg" ] && continue |
|
[ "x$ren" = "xDSC*.JPG" ] && continue |
|
[ "x$ren" = "xdsc*.jpg" ] && continue |
|
#@rotate_jpeg $DEST/$ren |
|
|
|
chmod a-x $DEST/$ren |
|
$JHEAD $JHEAD_OPTS $DEST/$ren |
done |
done |
|
|
# if we are not on battery, do CPU expensive job - decode RAW files to JPEG, |
# if we are not on battery, do CPU expensive job - decode RAW files to JPEG, |
Riadok 182 for i in img_*.crw img_*.cr2 IMG_*.CRW C |
|
Riadok 217 for i in img_*.crw img_*.cr2 IMG_*.CRW C |
|
|
|
if [ ! -f "$file.jpg" ]; then |
if [ ! -f "$file.jpg" ]; then |
echo --- $i; |
echo --- $i; |
|
chmod a-x $i |
$DCRAW -w $i # use white ballance set by camera |
$DCRAW -w $i # use white ballance set by camera |
$PPMTOJPEG $file.ppm > $file.jpg && rm -f $file.ppm ; |
$PPMTOJPEG $file.ppm > $file.jpg && rm -f $file.ppm ; |
|
else |
|
echo "===== Skipping RAW version of '$file.jpg'" |
|
continue |
fi |
fi |
|
|
# set EXIF information: |
# set EXIF information: |