1 #!@BASH_PATH@ 2 ############################################################ 3 # Wrapper for libraw and dcraw. 4 # Convert digital camera RAW files to 16bit PPMs. 5 # 6 # this is a stub with basic functionality 7 ############################################################ 8 9 if test -z "$1" || test "$1" = "--help" || test "$1" = "-h"; then 10 cat <<EOF 11 12 Read an image in a camera RAW file format supported by 13 LIBRAW or DCRAW and write pfs stream to the standard output 14 as if read from 16bit ppm file (no gamma correction, 15 white balance from camera if available). 16 17 Usage: pfsindcraw <file> [<file>...] 18 19 See the man page for more information. 20 21 EOF 22 exit 1 23 fi 24 25 # Use libraw's emulation of dcraw if available 26 libraw="/usr/lib/libraw/dcraw_emu" 27 if which $libraw 2>/dev/null 1>/dev/null; then 28 use_libraw=true 29 elif which dcraw_emu 2>/dev/null 1>/dev/null; then 30 use_libraw=true 31 libraw="dcraw_emu" 32 elif which dcraw 2>/dev/null 1>/dev/null; then 33 use_libraw=false 34 else 35 echo >&2 "pfsindcraw: neither libraw now dcraw program is found. Check if the program is installed and can be found in the PATH." 36 exit 1; 37 fi 38 39 if ! which pfsinppm 2>/dev/null 1>/dev/null; then 40 echo >&2 "pfsindcraw: pfsinppm program not found. Check if pfstools are compiled with netpbm support." 41 exit 1; 42 fi 43 44 COLORSPACE=1 45 # Arguments used for all images passed to pfsindcraw 46 global_arguments="" 47 if test -n "$1"; then 48 while test "${1:0:1}" = "-"; do 49 50 case "$1" in 51 "--native" | "-n") 52 # Use native (RAW) color space 53 COLORSPACE=0 54 ;; 55 "--dcraw" | "-d") 56 # Use dcraw instead of libraw 57 use_libraw=false 58 ;; 59 *) 60 echo >&2 "Unrecognized option '$1'." 61 exit 1; 62 esac 63 global_arguments="$global_arguments $1" 64 shift 65 done 66 fi 67 68 while test "$1"; do 69 70 # libraw-18 is unable to write to stdout. 71 # Future versions have option "-Z" for this purpose. 72 # TODO: change to -Z option once ubuntu switches to libraw-19 73 file_pattern="$1" 74 if $use_libraw; then 75 #temp_file=$(mktemp) 76 #cp $file_pattern $temp_file 77 #$libraw -o $COLORSPACE -4 -w $temp_file 78 #pfsinppm ${temp_file}.ppm | \ 79 # pfstag --set "FILE_NAME=${file_pattern}" --set "LUMINANCE=RELATIVE" 80 #rm $temp_file ${temp_file}.ppm 81 82 # Do not use temp (solves some issues on cygwin) 83 $libraw -o $COLORSPACE -4 -w $file_pattern 84 pfsinppm ${file_pattern}.ppm | \ 85 pfstag --set "FILE_NAME=${file_pattern}" --set "LUMINANCE=RELATIVE" 86 rm $temp_file ${file_pattern}.ppm 87 88 else 89 dcraw -c -o $COLORSPACE -4 -w "$file_pattern" | pfsinppm - 2> /dev/null | \ 90 pfstag --set "FILE_NAME=${file_pattern}" --set "LUMINANCE=RELATIVE" 91 fi 92 shift 93 done