freebsd-ports/graphics/pfscalibration/files/patch-src-jpeg2hdrgen
Danilo Egea Gondolfo 226c7a8e89 - Update from 1.3 to 1.4
- Add stage support
- Convert LIB_DEPENDS to new syntax

PR:		ports/191183
Submitted by:	ii@any.com.ru
2014-06-20 00:40:44 +00:00

135 lines
2.9 KiB
Text

--- src/jpeg2hdrgen.orig 2006-08-22 18:34:04.000000000 +0000
+++ src/jpeg2hdrgen 2014-06-18 15:27:14.288956550 +0000
@@ -28,53 +28,105 @@
export LC_ALL
-JHEAD="jhead" # program for extracting exif info from jpegs
-
-TEST_JHEAD=`which jhead`;
-if [ "$TEST_JHEAD" = "" ]; then
- echo "Program 'jhead' is required to run this script."
- echo "Install appropriate software, for example from:"
- echo "http://www.sentex.net/~mwandel/jhead/"
- exit 1;
-fi
-
-#Note: Double backslash MUST be put in front of each $ sign
-AWK_PROGRAM=`cat <<EOF
+AWK_PROGRAM_COMMON='
BEGIN {
exposure="";
aperture="";
}
END {
- if( aperture=="" )
+ if (aperture=="")
aperture=1;
- if( iso_speed=="" )
+ if (iso_speed=="")
iso_speed=100;
- if( exposure=="" )
+ if (exposure=="")
printf("not recognized exif header!\n");
else
print exposure " " aperture " " iso_speed " 0";
}
+'
+## jhead output
+AWK_PROGRAM_JHEAD='
/^Exposure time: ([0-9]*\.[0-9]) */ {
- exposure = 1/\\$3;
+ exposure = 1/$3;
+ next;
}
-
/^Aperture *: f\/([0-9]*\.[0-9]*)/ {
- aperture = substr(\\$3,3);
+ aperture = substr($3,3);
+ next;
}
-
/^ISO equiv. *: ([0-9]*\.?[0-9]*)/ {
- iso_speed = \\$4;
+ iso_speed = $4;
+ next;
+}'
+
+## exif output
+AWK_PROGRAM_EXIF='
+/^Exposure Time *\|.+ sec\./ {
+ if (split(substr($3,2),a,"/") == 2)
+ exposure = a[2];
+ else
+ exposure = 1/a[1];
+ next;
}
+/^FNumber *\|f\/.+/ {
+ aperture = substr($2,4);
+ next;
+}
+/^ISO Speed Ratings *\|.+/ {
+ iso_speed = substr($4,2);
+ next;
+}'
+
+## exiv2 output
+AWK_PROGRAM_EXIV2='
+/^ExposureTime *.+/ {
+ if (split($2,a,"/") == 2)
+ exposure = a[2]/a[1];
+ next;
+}
+/^FNumber *.+/ {
+ if (split($2,a,"/") == 2)
+ aperture = a[1]/a[2];
+ next;
+}
+/^ISOSpeedRatings *.+/ {
+ iso_speed = $2;
+ next;
+}'
+
+JHEAD='jhead' # program for extracting exif info from jpegs
+EXIV2='exiv2' # another one
+EXIF='exif' # and one more
+
+if which ${JHEAD} >/dev/null
+then
+ CMD="$(which ${JHEAD})"
+ AWK_PROGRAM="${AWK_PROGRAM_COMMON}${AWK_PROGRAM_JHEAD}"
+elif which ${EXIV2} >/dev/null
+then
+ CMD="$(which ${EXIV2}) -P nv pr"
+ AWK_PROGRAM="${AWK_PROGRAM_COMMON}${AWK_PROGRAM_EXIV2}"
+elif which ${EXIF} >/dev/null
+then
+ CMD="$(which ${EXIF})"
+ AWK_PROGRAM="${AWK_PROGRAM_COMMON}${AWK_PROGRAM_EXIF}"
+else
+ cat <<MSG
+One of the following commands are required to run this script:
+ '${JHEAD}' - stand-alone program (http://www.sentex.net/~mwandel/jhead/)
+ '${EXIV2}' - part of exiv2 project (http://www.exiv2.org/)
+ '${EXIF}' - part of libexif project (http://sf.net/projects/libexif/)
+MSG
+ exit 1;
+fi
-EOF`
-
-while [ "$1" != "" ]; do
- EXPOSURE_INFO=`$JHEAD $1 | awk "$AWK_PROGRAM"`
- echo $1 $EXPOSURE_INFO
-
+while [ ${#} -ne 0 ]
+do
+ printf "${1} "
+ ${CMD} "${1}" | awk "${AWK_PROGRAM}"
shift
-done
+done