aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Steiner <jimmac@charon.jimmac.net>2008-06-24 12:18:55 +0200
committerJakub Steiner <jimmac@charon.jimmac.net>2008-06-24 12:18:55 +0200
commitc80b899f5277b31af90809ff9798fcfd4746df7a (patch)
tree5735ea610ba9dc66b4a487c7a171ef9967542ffa
parentab2251c63511596bd0b5d69b8b538bd9e847836d (diff)
downloadoriginal-c80b899f5277b31af90809ff9798fcfd4746df7a.tar.gz
original-c80b899f5277b31af90809ff9798fcfd4746df7a.tar.bz2
Patch by Bailey Kong <bailey@tgpsolutions.com> to support image autorotation and .jpg extension
-rwxr-xr-xconvert/imgconv34
1 files changed, 29 insertions, 5 deletions
diff --git a/convert/imgconv b/convert/imgconv
index 84a9bbc..396a786 100755
--- a/convert/imgconv
+++ b/convert/imgconv
@@ -11,6 +11,7 @@
#default options
dir=./web-gallery
zip=0
+rotate=0
mq=0
hq=0
interactive=0
@@ -26,15 +27,16 @@ gal_pass=""
# convert options
convertor=`which convert`
+jhead=`which jhead`
extra_ops="-strip"
# This script
name=`basename $0`
# getopt stuff
-shortopts="a:hHin:d:D:Mqo:Z"
+shortopts="a:hHin:d:D:Mqo:Zr"
longopts="author:quiet,help,interactive,name:,date:,description:,\
-mq,hq,output:,archive"
+mq,hq,output:,archive,rotate"
@@ -52,10 +54,11 @@ Convert FILEs
-n, --name NAME set gallery's name
-d, --date DATE set date to DATE
-D, --description DESC description
+ -r, --rotate automatically rotate image based on EXIF
-q, --quiet don't say anything
-h, --help display this help and exit
-FILEs must be JPEG or PNG. if DIR is not given, the
+FILEs must be JPG, JPEG or PNG. if DIR is not given, the
gallery will be created in $dir.
EOF
@@ -67,7 +70,7 @@ good_file() {
ftype=`file -b "$1" | cut -d " " -f 1`
- if [ "$ftype" == "JPEG" ] || [ "$ftype" == "PNG" ]
+ if [ "$ftype" == "JPG" ] || [ "$ftype" == "JPEG" ] || [ "$ftype" == "PNG" ]
then
return 0
else
@@ -115,6 +118,9 @@ while true; do
-Z|--zip)
zip=1 ; shift ;;
+ -r|--rotate)
+ rotate=1 ; shift ;;
+
-q|--quiet)
verbose=false ; shift ;;
@@ -133,6 +139,15 @@ while true; do
done
+
+# If we don't have JHead and we want to auto-rotate images, cry & exit
+if [ $rotate -gt 0 ] && [ -z $jhead ]; then
+ echo "jhead not found... Please install JHead."
+ exit 1
+fi
+
+
+
# If no input files are given, display usage & exit
if [ $# == 0 ]; then
cat <<EOF
@@ -169,7 +184,7 @@ for imagefile in $files; do
good_file "$imagefile"
if [ $? != 0 ]; then
- $verbose "$imagefile is not a JPEG or PNG file, skipped"
+ $verbose "$imagefile is not a JPG, JPEG or PNG file, skipped"
continue
fi
@@ -202,6 +217,15 @@ for imagefile in $files; do
$verbose " done"
done
+# auto-rotate stuff
+if [ $rotate -gt 0 ]; then
+ $verbose "rotating"
+ jhead -autorot $dir/thumbs/*.jpg
+ jhead -autorot $dir/lq/*.jpg
+ [ $mq ] && jhead -autorot $dir/mq/*.jpg
+ [ $hq ] && jhead -autorot $dir/hq/*.jpg
+fi
+
# zip stuff
if [ $zip -gt 0 ]; then
$verbose "archiving"