#!/bin/sh USAGE=' Usage: brewraw [options] [all dcraw options except -o -T -b] Batch REWork RAW. A simple linux bash shell script for automatic high-quality (16-bit) decoding and post-processing of raw-images, preserving original EXIF-tags from the raw-format. The following is performed: decoding with dcraw including noise removal, adjustment of exposure value, application of non-linear curve, histogram normalization, application of colorprofiles (Canon 5D/5D3/6D, Pentax K10D), sigmoidal contrast tone-curve, and highlight stretching. JPEG is always 8-bit, defaults to sRGB colorspace, and is saved as default. TIFF is always in Adobe RGB colorspace, never sharpened, defaults to 16-bit, and is not saved as default. Uses Capture One color profiles. Note that aberration correction performed in-camera is never saved to RAW-file for Canon EOS 5DM3, and possibly no other cameras. For option -slidecopy this script corrects for chromatic lens aberrations, peripheral illumination, and lens distortion assuming lens Canon EF24-17mm/4L IS USM with Extension Tube EF12II with magnification x1.0 in macro mode. Correct fixed exposure for -slidecopy (implying -noev) using gepe G-2003 light-panel is F6.3, 1/5s Depends on dcraw, ImageMagick, Netpbm, exiftool, awk and brewtool. Copyright © Daniel Ljunggren . Version 0.54 (dcraw ver. 9.27) 2007 - 2016. [options]: -s : save with special suffix .jpg/.tif -tiff : process TIFF in 16-bit saved as _r16.tif -tiff8 : process TIFF in 8-bit saved as _raw.tif -jpeg : process JPEG in 8-bit saved as _raw.jpg (default) -nosave : delete non-preexisting JPEG or TIFF after processing -o : overwrite existing file -adobe : save JPEG in Adobe RGB colorspace instead of sRGB -display : save JPEG in display (monitor) colorspace instead of sRGB -nosharp : no sharpening applied to JPEG -sharp : less or more sharpening, none=0, default=1.0, strong=2 (force to sharpen TIFF) -preview : quick resize to UHD 4K but preserved ratio, i.e. 2160 pixels in smallest dimension, -copyorient : force to set EXIF-tag -CameraOrientation to -Orientation (dcraw reads -CameraOrientation) -colortemp : color temperature set in Kelvin degrees (Canon 5D/5DM3 supported), to `camera` (default), or `measured` -red | -green | -blue : grayscale image using specified color channel -gray | -color : grayscale or color image -sepia | -bluetone : sepia or bluetone image -wedding : enhance highlights with sigmoidal-contrast -vivid : enhance contrast and saturation with polynomial and sigmoidal-contrast -noise : less or more noise reduction, none=0, default=1.0, strong=3.3 -noev : ignore EXIF-tag "Exposure Compensation" from raw-file -ev : exposure compensation in floating stops <..-3,-2,-1,0,1,2,3..> -gamma : gamma adjustment in floating points, default=1.0 -bvalue : force pixel-value to black (black-point, default 1%) -wvalue : force pixel-value to white (white-point, default 0.5%) -maxexpand : set max expansion of histogram normalisation (default 50%) -darkframe : subtract darkframe (dcraw on default looks up .badpixels if exists) -slidecopy : slide film image copy performs lens aberration correction, increased saturation and cut image edges (implies -noev) -negative : used with option -slidecopy to invert negative image (performs channel level normalization, -colortemp has no effect) -blend : blend multiple exposures into single image using next number of images (psuedo HDR) -useraw : apply operations to corresponding raw file in current folder given processed image file name and folder -4K : uses `brewtool` to generate UHD 4K jpeg image preserved ratio, implying -nosave. -web : uses `brewtool` to generate www jpeg image, implying -nosave. -thumbS|thumbM|thumbL : uses `brewtool` to generate small or medium thumb jpeg image, implying -nosave. -getty : uses `brewtool` to generate gettyimage ready tiff image, implying -nosave. -bt "" : sends image to `brewtool ` for postprocessing, implying -nosave. ' CHANGELOG=' TODO: Interchange Software and ProcessingSoftware, also in brewtool!!! Changelog: brewraw 160703: v0.54 # Update to dcraw 9.27 160426: v0.53 # Added option -blend for blending multiple exposures (psuedo HDR). 160209: v0.52 # Added option -useraw to specify any file name (e.g with jpg extension) and apply operations to corresponding raw file in current folder. 151206: v0.51 # Finetune wedding sigmoidal parameters with new 4K monitor Dell P2715Q 151030: v0.50 # Update to dcraw 9.25 150208: v0.49 # Added option -4K. 150131: v0.48 # Added option -preview. 140826: v0.47 # Update to dcraw 9.22 140404: v0.46 # Added option -slidecopy and -negative. Unsharp now done in CIELab color space using luminescence channel. # Various other changes and fixes. 140126: v0.45 # Update to dcraw 9.20 131124: v0.44 # Changed "convert ppm:-" to "convert -" due to some bug issue (?) with stdin in ImageMagick (since Fedora 19) Update to dcraw 9.19. 121022: v0.43 # Added option -vivid. Found bug in sigmoidal-contrast parameter; now using %! Additional contrast cleanup. 121014: v0.42 # Update to dcraw 9.16. Sent bug report to Dave Coffin regarding bug in 9.16 (dcraw -o 0 -h). (Temporary fix on line 3931: mix_green = four_color_rgb; //=!half_size;) Changes for Canon 5DM3: Introduced new NOISE_THRESHOLD function and NOISEFACTOR set to 1 for Canon 5DM3 and 7 for 5D, default 5. RADIUS and SIGMA now normalize to ${SENSOR_SIZE}. New color profiles for Canon 5D and 5DM3. Removed -XMP:all= in exiftool to get back Flash tag. 110701: v0.41 # Updated to dcraw 9.08. 110513: v0.40 # Updated to dcraw 9.07. 110502: v0.39 # Updated to dcraw 9.06. Added option -copyorient as a fix for malfunctioning orientation sensor on camera, making it now work with dcraw 9.04 and later. 101215: v0.38 # Replaced EXIF tag Software with ProcessingSoftware (now also with command line). 100830: v0.37 # Updated to dcraw 9.03. (Change in 9.04 and later: flips/rotates images based on EXIF-tag -CameraOrientation instead of -Orientation. DOES NOT WORK for broken sensor on my Canon 5D) 100627: v0.36 # Added option -o. 100606: v0.35 # Updated to dcraw 8.99. Fixed wrong notation in sigmoidal-contrast from 17,35% to 17x35. The sigmoidal operation was silently ignored. Added -wedding option. 100403: v0.34 # Changed so that option -sharp sharpens TIFF. 090226: v0.33 # Updated to dcraw 8.95. Changed to using pamfunc ${EXPCOMP}/100 due to some bug in updated tools Netpbm or convert (?) which gives pink highlights when exposure is < 0 ? 090226: v0.32 # Added option -maxexpand. 090208: v0.31 # Added option -thumbS and -thumbM. 090116: v0.30 # Added option -web and -getty. 081104: v0.29 # Changed the way tiff and jpeg are saved. 080927: v0.28 # Added options -bt and -nojpeg. 080530: v0.27 # Added [ ${EXPVALUECAM} -gt 0 ] condition for daylight flash MAXEXPAND2. 080520: v0.26 # Added Pentax K10D input profile from CaptureOne. 080323: v0.25 # Added option -o; dcraw option -m 3 (median filter); including new NOISE_THRESHOLD factor set to 6. 080224: v0.24 # Changed dcraw options (-o 0 in place of -m) including the NOISE_THRESHOLD factor from 3 to 9 to accompany unknown changes in dcraw v8.80; New version effective of Imagemagick 6.3.5 with 16bit and no HDRI (no longer private patch for Unsharp in effect.c). 071219: v0.23 # Changed default COLOR_TEMP from "measured" to "camera" to keep colors sane in extreme lighting conditions. 070510: v0.22 # Renamed scipt from rawimages to brewraw; New decoding and postprocessing part: Implemented color profiling with 'convert' instead of 'tifficc' before extra pnmnorm to stretch image. New version effective of Imagemagick 6.3.4 with 32bit and HDRI (private patch for Unsharp in effect.c); Change grayscale handling to use profiles; sepia, bluetone, applies now also to TIFF; Sigmoidal contrast curve added; Second histogram normalization added; Set color temperature option added. 070508: v0.21 # Added switch -darkframe; Added dcraw feature using .badpixels file. Unsharp AMOUNT decreased from 4.0 to 2.0 070504: v0.20 # Added switches -wvalue and -bvalue. 070225: v0.10 # dcraw updated to v8.61 from v8.43; Unsharp AMOUNT increased from 2.0 to 4.0 ' ### SYSTEM DEPENDENT FILES ### ICCCATALOG="/usr/share/color/icc" #CANON5D_PROFILE="${ICCCATALOG}/Canon5D_Canon.icm" #CANON5D_PROFILE="${ICCCATALOG}/Canon5D_Canon/6111_std.ICC" # Someone suggested 6091... #CANON5D_PROFILE="${ICCCATALOG}/Canon5D_DLC.icm" # Good gray, bad color #CANON5D_PROFILE="${ICCCATALOG}/Canon5D_BibblePro/canon1.icm" # Shity gray, fair color #CANON5D_PROFILE="${ICCCATALOG}/CaptureOne/Canon5D_CaptureOne.icm" # Default, good color, grainy in gray CANON5D_PROFILE="${ICCCATALOG}/CaptureOne/CanonEOS5D-Generic_CaptureOne.icm" # New 121016 from CaptureOne 6.4.4 CANON5DM3_PROFILE="${ICCCATALOG}/CaptureOne/CanonEOS5DMk3-Generic_CaptureOne.icm" # New 121016 from CaptureOne 6.4.4 (unchanged in 9.0.0) CANON6D_PROFILE="${ICCCATALOG}/CaptureOne/CanonEOS6D-Generic_CaptureOne.icm" # New 151212 from CaptureOne 9.0.0 PENTAXK10D_PROFILE="${ICCCATALOG}/CaptureOne/PentaxK10D_CaptureOne.icm" ARGB_PROFILE="${ICCCATALOG}/AdobeRGB1998.icc" SRGB_PROFILE="${ICCCATALOG}/sRGB.icc" DISPLAY_PROFILE="${ICCCATALOG}/Dell2407WFP.icm" GRAY_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-B&W.icm" PANCROM_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-B&WPanchromatic.icm" YELLOW_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-B&WYellowfilter.icm" SEPIA_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-Sepia.icm" COLORVIEW_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-Colorview" BLUETONE_PROFILE="${ICCCATALOG}/CaptureOne/PhaseOneEffects-Bluetone.icm" CIELAB_PROFILE="${ICCCATALOG}/lcms/Lab.icc" DARKFRAMEFILE="/data/FotoBanken/CanonEOS5D/.darkframe" CanonEOS5D_WBTORGGBFILE="/data/FotoBanken/CanonEOS5D/whitebalance/WBtoRGGB.table" CanonEOS5DM3_WBTORGGBFILE="/data/FotoBanken/CanonEOS5DM3/whitebalance/WBtoRGGB.table" CanonEOS6D_WBTORGGBFILE="/data/FotoBanken/CanonEOS5DM3/whitebalance/WBtoRGGB.table" VIGNCORRFILE="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction.ppm" VIGNCORRFILE_L="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction_left.ppm" VIGNCORRFILE_4K="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction_4k.ppm" VIGNCORRFILE_4KL="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction_4k_left.ppm" VIGNCORRFILE_H="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction_half.ppm" VIGNCORRFILE_HL="/data/FotoBanken/Testbilder/Diaduplikator/CanonEOS5DM3_EF24-70mmf4_macro_EF12II_vignetting_raw_correction_half_left.ppm" ############################## SOFTWARE="brewraw v0.54 (dcraw v9.27) [brewraw $@]" OVRWRT=false GENERATE_TIF=false GENERATE_JPG=true NODELETE=true GENERATE_UHD=false GENERATE_WEB=false GENERATE_THUMB=false GENERATE_GETTY=false SUFFIX="defaultsuffix" BITDEPTH=16 SIZE=full SWITCHES="" NOSHARP=false NOSHARPTIFF=true NOISELEVEL=1 NOISEFACTOR=5; SHARP=1 EXPVALUE=0 EXPCAM=true GAMMAADJ=1.0 CHANNEL="Default" DCRAW=dcraw WVALUE=auto BVALUE=auto MAXEXPAND1=50 USEDARKFRAME=false SLIDECOPY=false MULTEXP=1 BREWTOOL="" BTSWITCH= #"-nosw" # Avoid brewtool owerwriting tag EXIF:Software COLOR_TEMP="camera" WEDDING=false VIVID=false PROFILE="sRGB" # The default profile. Other option "Adobe RGB (1998)". COPYORIENT=false NEGATIVE=false PASSES=3 USERAW=false while [ $# -gt 0 ] do case "$1" in -tiff) GENERATE_TIF=true GENERATE_JPG=false NODELETE=yes ;; -tiff8) GENERATE_TIF=true GENERATE_JPG=false BITDEPTH=8 NODELETE=yes ;; -jpeg) GENERATE_JPG=true NODELETE=yes ;; -nosave) NODELETE=false ;; -o) OVRWRT=true ;; -preview) SIZE=uhd4k ;; -s) SUFFIX=$2 shift 1 ;; -adobe) PROFILE="Adobe RGB (1998)" ;; -display) PROFILE="display" ;; -nosharp) NOSHARP=true ;; -noise) NOISELEVEL=$2 shift 1 ;; -sharp) SHARP=$2 NOSHARPTIFF=false shift 1 ;; -noev) EXPCAM=false ;; -ev) EXPVALUE=$2 shift 1 ;; -gamma) GAMMAADJ=$2 shift 1 ;; -wvalue) WVALUE=$2 shift 1 ;; -bvalue) BVALUE=$2 shift 1 ;; -maxexpand) MAXEXPAND1=$2 shift 1 ;; -copyorient) COPYORIENT=true ;; -colortemp) COLOR_TEMP=$2 shift 1 ;; -red) CHANNEL="Red" ;; -green) CHANNEL="Green" ;; -blue) CHANNEL="Blue" ;; -gray) CHANNEL="Gray" ;; -color) CHANNEL="Index" ;; -sepia) CHANNEL="Sepia" ;; -wedding) WEDDING=true ;; -vivid) VIVID=true ;; -bluetone) CHANNEL="Bluetone" ;; -darkframe) USEDARKFRAME=true ;; -slidecopy) SLIDECOPY=true EXPCAM=false COPYORIENT=true ;; -negative) NEGATIVE=true ;; -blend) MULTEXP=$2 if [ "${SUFFIX}" == "defaultsuffix" ]; then SUFFIX="_blend"; fi shift 1 ;; -useraw) USERAW=true ;; -4K) GENERATE_TIF=true GENERATE_JPG=false GENERATE_UHD=true NODELETE=false BITDEPTH=8 ;; -web) GENERATE_JPG=true # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? GENERATE_WEB=true #SWITCHES="-h" NODELETE=false ;; -thumbS) GENERATE_JPG=true # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? GENERATE_THUMB=true THUMBCOMMAND="thumbS -noexif" #SWITCHES="-h" NODELETE=false ;; -thumbM) GENERATE_JPG=true # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? GENERATE_THUMB=true THUMBCOMMAND="thumbM" #SWITCHES="-h" NODELETE=false ;; -thumbL) GENERATE_JPG=true # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? GENERATE_THUMB=true THUMBCOMMAND="thumbL" #SWITCHES="-h" NODELETE=false ;; -getty) GENERATE_TIF=true GENERATE_JPG=false GENERATE_GETTY=true NODELETE=false BITDEPTH=16 ;; -bt) BREWTOOL=$2 NODELETE=false shift 1 ;; -help) echo "${USAGE}" exit 0 ;; -*) if [ "$2" == "-*" ] || [ -f "$2" ]; then SWITCHES="${SWITCHES} $1" else SWITCHES="${SWITCHES} $1 $2" shift 1 fi ;; *) break ;; esac shift 1 done if [ $# -eq 0 ]; then echo "${USAGE}" ; fi # Define a calculator with max() and min() based on awk function calc () { awk "function max(a, b) { if (a > b) {return a} else {return b} }; function min(a, b) { if (a < b) {return a} else {return b} }; BEGIN { print $* ; }" } # Returns OK if $1 contains $2 strstr() { [ "${1#*$2*}" = "$1" ] && return 1 return 0 } for FILE do if [ -w "$FILE" ] || [ ${USERAWFILE} == "true" ]; then if [ ${USERAW} == "true" ]; then BASE=`basename $FILE` PREFILENAME=`expr $BASE : '\(.*[0-9][0-9][0-9][0-9][0-9][0-9]_[a-z][0-9][0-9][0-9][0-9]\).*$'` FILE="${PREFILENAME}.cr2" if [ ! -w "$FILE" ]; then echo "brewraw: File '$FILE' does not exist or has no write permissions! Skipping..." 1>&2 continue fi fi case "$FILE" in *.raw) ORIG_EXT=raw ;; *.RAW) ORIG_EXT=RAW ;; *.crw) ORIG_EXT=crw ;; *.CRW) ORIG_EXT=CRW ;; *.cr2) ORIG_EXT=cr2 ;; *.CR2) ORIG_EXT=CR2 ;; *.DNG) ORIG_EXT=DNG ;; *.dng) ORIG_EXT=dng ;; *.pef) ORIG_EXT=pef ;; *.PEF) ORIG_EXT=PEF ;; *) echo "brewraw: Can't handle file '$FILE', only .dng, .raw, .crw, or .cr2 are valid files without option -rawfile, skipping" 1>&2 continue ;; esac echo "brewraw: Processing $FILE..." 1>&2 MODEL=`exiftool -Model ${FILE} | cut -b35-` ISOVALUE=`exiftool -ISO ${FILE} | cut -b35-` GRAY_SWITCHES="" GRAYSCALE="" WIDTH="" HEIGHT="" DISTCORR="" EDGE="" COLORTINT="" VIGNCORR="" INVERT="" WRITE_TIF="" WRITE_JPG="" SCALE="" ################### # Orientation tag # ################### # Ask to copy EXIF-tag Orientation to CameraOrientation if different (omit if missing as on EOS5DM3), as Dcraw # wrongly uses CameraOrientation (fixed in dcraw 9.16?). This is a fix for broken orientation-sensor on my # camera EOS5D, where only Orientation tag is set on manual in-camera rotation. ORIENTTAG=`exiftool -p '$Orientation' $FILE` CAMORIENTTAG=`exiftool -p '$CameraOrientation' $FILE` if [ "$ORIENTTAG" != "$CAMORIENTTAG" ] && [ ! -z "$CAMORIENTTAG" ] ; then answer=Y if [ $COPYORIENT == "false" ]; then echo -n "brewraw: CameraOrientation [$CAMORIENTTAG] and Orientation [$ORIENTTAG] are different. Fix? [Y/n] " read answer fi if strstr $"yY" "$answer" || [ "$answer" = "" ]; then brewtool -cameraorienttag -o $FILE fi fi ##################### # Color temperature # ##################### # CCD format: R G G B (groups of four pixels), dcraw format: R G B G if [ "${COLOR_TEMP}" == "camera" ]; then COLOR_TEMPVAL=`exiftool -ColorTempAsShot ${FILE} | cut -b35-` echo "brewraw: Color temperature as shot by camera: ${COLOR_TEMPVAL} Kelvin" 1>&2 COLOR_TEMP_SWITCH="-w" elif [ "${COLOR_TEMP}" == "measured" ]; then COLOR_TEMPVAL=`exiftool -ColorTempMeasured ${FILE} | cut -b35-` COLOR_TEMPVALSHOT=`exiftool -ColorTempAsShot ${FILE} | cut -b35-` RGGB_LEVELS=`exiftool -WB_RGGBLevelsMeasured ${FILE} | cut -b35-` #RGGB_LEVELS=`exiftool -MeasuredRGGB ${FILE} | cut -b35-` # Use this for multiexposures in CanonEOS5DM3 but why!? echo "brewraw: Color temperature measured by camera: ${COLOR_TEMPVAL} Kelvin (as shot ${COLOR_TEMPVALSHOT} K)" 1>&2 RG=`expr "${RGGB_LEVELS}" : '\([0-9]*\s[0-9]*\)\s.*$'` G=`expr "${RGGB_LEVELS}" : '[0-9]*\s[0-9]*\s\([0-9]*\)\s.*$'` B=`expr "${RGGB_LEVELS}" : '[0-9]*\s[0-9]*\s[0-9]*\s\([0-9]*\).*$'` RGBG="${RG} ${B} ${G}" COLOR_TEMP_SWITCH="-r ${RGBG}" else COLOR_TEMPVAL="${COLOR_TEMP}" if [ "${MODEL}" == "Canon EOS 5D Mark III" ]; then WBTORGGBFILE=${CanonEOS5DM3_WBTORGGBFILE} elif [ "${MODEL}" == "Canon EOS 5D" ]; then WBTORGGBFILE=${CanonEOS5D_WBTORGGBFILE} elif [ "${MODEL}" == "Canon EOS 6D" ]; then WBTORGGBFILE=${CanonEOS6D_WBTORGGBFILE} else echo "brewraw: Colortemp in Kelvin can only be set for Canon EOS 5D, 5DM3 abd 6D" 1>&2 exit 1 fi echo "brewraw: Color temperature is set to ${COLOR_TEMPVAL} Kelvin for ${MODEL}" 1>&2 READLINE=`cat ${WBTORGGBFILE} | grep $COLOR_TEMPVAL` RGBG=`expr "${READLINE}" : '.*: \(.*\)$'` if [ -z "${RGBG}" ]; then echo "brewraw: Set colortemp values in steps of 100 Kelvin ranging from 2800 to 10000" 1>&2 exit 1 fi COLOR_TEMP_SWITCH="-r ${RGBG}" fi ######################### # Output color profiles # ######################### # The PNM conversion destroys the profile header so we need to reset profile. #PROFILE=`exiftool -ProfileDescription ${T16_FILE} | cut -b35-` if [ "${PROFILE}" == "Adobe RGB (1998)" ]; then OUT_PROFILE="${ARGB_PROFILE}" INTEROP=R03 COLORSP=Uncalibrated elif [ "${PROFILE}" == "sRGB" ]; then OUT_PROFILE="${SRGB_PROFILE}" INTEROP=R98 COLORSP=sRGB elif [ "${PROFILE}" == "display" ]; then # Monitor proof profile: OUT_PROFILE="${DISPLAY_PROFILE}" INTEROP=R98 COLORSP=sRGB fi OUT_PROFILE_TIFF="${ARGB_PROFILE}" INTEROP_TIFF=R03 COLORSP_TIFF=Uncalibrated ######################## # Input color profiles # ######################## # Watchout: do not apply these profiles directly on a 16-bit _linear_ dcraw output by -p and -o options!! # Color profiling, camera input profile: if [ "${MODEL}" == "Canon EOS 5D Mark III" ]; then IN_PROFILE="${CANON5DM3_PROFILE}" elif [ "${MODEL}" == "Canon EOS 5D" ]; then IN_PROFILE="${CANON5D_PROFILE}" elif [ "${MODEL}" == "Canon EOS 6D" ]; then IN_PROFILE="${CANON6D_PROFILE}" elif [ "${MODEL}" == "PENTAX K10D" ]; then IN_PROFILE="${PENTAXK10D_PROFILE}" # Generic else IN_PROFILE="${ARGB_PROFILE}" fi ############# # Grayscale # ############# # 1. Makes ugly rastering patterns in images: DCRAW_SWITCHES="${DCRAW_SWITCHES} -d" # 2. NEVER USE 'convert -type GrayScale' as it converts to 8-bit and makes color artifacts! # 3. GRAY_SWITCHES="-colorspace HSL -channel luminosity -separate +channel -colorspace RGB -sigmoidal-contrast 2,60%" # 4. Idea for ideal Gray conversion: most blue, some green, and least red to mimic B&W film color sensitivity. # 5. Best seems to use B&W color profiles. GRAYSCALE=`exiftool -PictureStyle $FILE | cut -b35-` if [ "${GRAYSCALE}" == "Monochrome" ] && [ "${CHANNEL}" == "Default" ] || [ "${CHANNEL}" == "Gray" ]; then IN_PROFILE="${GRAY_PROFILE}" elif [ "${CHANNEL}" == "Red" ] || [ "${CHANNEL}" == "Green" ] || [ "${CHANNEL}" == "Blue" ]; then GRAY_SWITCHES="-channel ${CHANNEL} -separate +channel" IN_PROFILE="${GRAY_PROFILE}" elif [ "${CHANNEL}" == "Sepia" ]; then IN_PROFILE="${SEPIA_PROFILE}" elif [ "${CHANNEL}" == "Bluetone" ]; then IN_PROFILE="${BLUETONE_PROFILE}" fi echo "brewraw: Camera profile: ${IN_PROFILE}..." 1>&2 ######################### # Exposure compensation # ######################### # ppmbrighten use "100*(2^${EXPVALUE}-1)" FLASH=`exiftool -Flash ${FILE} | cut -b35-` if [ ${EXPCAM} == "true" ]; then EXPVALUECAM=`exiftool -ExposureCompensation ${FILE} | cut -b35-` EXPVALUEFLASH=`exiftool -FlashExposureComp ${FILE} | cut -b35-` if [ "${EXPVALUECAM}" == "" ]; then echo "brewraw: Warning, no EXIF data field EXPVALUECAM..." 1>&2 EXPVALUECAM=0; fi if [ "${EXPVALUEFLASH}" == "" ]; then echo "brewraw: Warning, no EXIF data field EXPVALUEFLASH..." 1>&2 EXPVALUEFLASH=0; fi if [ "${FLASH}" == "On, Fired" ]; then EXPVALUECAM=$(calc "max(${EXPVALUECAM}, ${EXPVALUEFLASH})") fi else EXPVALUECAM=0 fi # Do not overexpose based on camera setting. EXPOSURE=$(calc "${EXPVALUE} + min(0,${EXPVALUECAM})") EXPCOMP=$(calc "100*(2^($EXPOSURE))") # Using convert -modulate ${EXPCOMP}... #EXPCOMP=$(calc "100*(2^($EXPOSURE))-100") # Using ppmbrighten ${EXPCOMP} #################### # Gamma adjustment # #################### GAMMA=$(calc "1.0*${GAMMAADJ}") ################## # Image geometry # ################## WIDTH=`exiftool -CanonImageWidth ${FILE} | cut -b35-` if [ "${WIDTH}" == "" ]; then WIDTH=`exiftool -ImageWidth ${FILE} | cut -b35-` fi HEIGHT=`exiftool -CanonImageHeight ${FILE} | cut -b35-` if [ "${HEIGHT}" == "" ]; then HEIGHT=`exiftool -ImageHeight ${FILE} | cut -b35-` fi SENSOR_SIZE=$(calc "max(${WIDTH},${HEIGHT})") HALF_SIZE=$(calc "0.5*max(${WIDTH},${HEIGHT})") UHD4K_SIZE="3240" # Longest side using format 2:3 with shortest side 2160 echo "${SWITCHES}" | grep -q " -h" && HALF=$? if [ "$HALF" == 0 ]; then SIZE="half"; fi case $SIZE in full) IMAGE_SIZE=${SENSOR_SIZE} ;; half) IMAGE_SIZE=${HALF_SIZE} # Very fast size reduction in dcraw. ;; uhd4k) IMAGE_SIZE=${UHD4K_SIZE} SCALE="pamscale -xyfill 2160 2160 -linear" # Method 'pixel mixing' does not preserve colors exactly, see pamscale. #SCALE="pamscale -xyfill 2160 2160 -filter=sinc" # Method 'sinc' makes sharper image but is much slower. ;; esac CAMERAORIENTATION=`exiftool -CameraOrientation# ${FILE} | cut -b35-` ############# # Denoising # ############# # Wavelet denoising filter parameters. Stronger reduction for higher ISO, prop to sqrt(ISO). # MATLAB: iso=logspace(log10(100),log10(102400),100); semilogx(iso, 6*sqrt(iso), iso, 1.5*sqrt(iso)); if [ ${SLIDECOPY} == "true" ]; then NOISEFACTOR=8; elif [ "${MODEL}" == "Canon EOS 5D Mark III" ]; then NOISEFACTOR=1; elif [ "${MODEL}" == "Canon EOS 5D" ]; then NOISEFACTOR=7; fi #NOISE_THRESHOLD=$(calc "${NOISEFACTOR}*(${NOISELEVEL}*${ISOVALUE})^(1/2)") # NOISEFACTOR=1.5 (5DM3) and 6 (5D) NOISE_THRESHOLD=$(calc "0.12*${NOISEFACTOR}^2*(${NOISELEVEL}*${ISOVALUE})^(1/2*(7/${NOISEFACTOR})^(0.256))") echo "brewraw: Exposure compensation: $EXPOSURE stops at ISO $ISOVALUE and with Flash: $FLASH" 1>&2 if [ ${ISOVALUE} -lt 1250 ] && [ "${MODEL}" == "Canon EOS 5D Mark III" ] && [ ${SLIDECOPY} == "false" ]; then NOISESWITCH=""; else NOISESWITCH="-n ${NOISE_THRESHOLD}"; echo "brewraw: Wavelet denoising threshold=${NOISE_THRESHOLD}" 1>&2 fi ######################## # Other repair options # ######################## # Darkframe subtraction if [ ${USEDARKFRAME} == "true" ]; then SWITCHES="-K $DARKFRAMEFILE ${SWITCHES}" fi # Darkness and Saturation if [ "${MODEL}" == "Canon EOS 5D Mark III" ]; then SWITCHES="-S 14000 ${SWITCHES}" # Default level 15488 for 5DM3 gives pink tones. fi ############################# # Slide copy repair options # ############################# if [ ${SLIDECOPY} == "true" ]; then # Chromatic aberration correction # Good values with EF24-70 mm 4.0/L + EF12 mm extension: 1.0010 0.9986 , 1.0010 0.9990, 1.0009 0.9980, 1.0011 0.9980 SWITCHES="-C 1.0008 0.9983 ${SWITCHES}" # NO VIGNETTING CORRECTION FOR NEGATIVES YET!! # Vignetting (peripheral illumination) correction for EF24-70 mm 4.0/L + EF12 mm extension tube # (convert vignetting_EF24-70mmf4_macro_EF12II_raw_correction.jpg +swap -compose divide -composite) # (pamarith -divide - vignetting_EF24-70mmf4_macro_EF12II_raw_correction.ppm) if [ ! ${NEGATIVE} == "true" ] && [ "${MODEL}" == "Canon EOS 5D Mark III" ]; then # Correction image size needs to match sensor size if [[ ${SIZE} == "half" ]]; then if [[ ${CAMERAORIENTATION} == 0 ]]; then VIGNCORRFILE=${VIGNCORRFILE_H} else VIGNCORRFILE=${VIGNCORRFILE_HL} fi elif [[ ${SIZE} == "uhd4k" ]]; then if [[ ${CAMERAORIENTATION} == 0 ]]; then VIGNCORRFILE=${VIGNCORRFILE_4K} else VIGNCORRFILE=${VIGNCORRFILE_4KL} fi else if [[ ${CAMERAORIENTATION} == 0 ]]; then VIGNCORRFILE=${VIGNCORRFILE} else VIGNCORRFILE=${VIGNCORRFILE_L} fi fi VIGNCORR="pamarith -divide - ${VIGNCORRFILE}" fi # Distortion correction for EF24-70 mm 4.0/L + EF12 mm extension (a=0.0066 b=-0.02761 c=0.02436 found using Hugin) DISTCORR="-distort barrel 0.0066,-0.02761,0.02436" # Cut image edges if [ ${SIZE} == "half" ]; then if [ ${CAMERAORIENTATION} == 0 ]; then CROPOFFSET="+0+20" else CROPOFFSET="+20+0" fi elif [[ ${SIZE} == "uhd4k" ]]; then if [[ ${CAMERAORIENTATION} == 0 ]]; then CROPOFFSET="+0+22" else CROPOFFSET="+22+0" fi else if [ ${CAMERAORIENTATION} == 0 ]; then CROPOFFSET="+0+40" else CROPOFFSET="+40+0" fi fi #EDGE="-gravity center -shave 3.75%x3.75%" # ~217x145, other example: 102x68 EDGE="-gravity center -crop 92.5%x92.5%${CROPOFFSET}" # #EDGE="-shave 13%x3.75%" # Fix yellow color tint by increasing blue (0% to affect only brightness) # See sigmoidal_contrast_imagemagick.m # NEED A COLOR CHART AND CALIBRATED MONITOR TO TEST IF NEEDED #COLORTINT="-channel B -sigmoidal-contrast 1x0% +channel" #COLORTINT=" -sigmoidal-contrast 2x0% " # See also Contrast curve below fi if [ ${NEGATIVE} == "true" ]; then INVERT="pnminvert" MAXEXPAND1=0 fi ################## # dcraw switches # ################## if [ $SIZE = "uhd4k" ]; then PASSES=1; SWITCHES="-q 0 ${SWITCHES}"; # High-speed, low-quality bilinear interpolation makes slighly blurred image, but ok with increased sharp factors. fi DCR16_SWITCHES="-v ${COLOR_TEMP_SWITCH} -o 0 -m ${PASSES} ${NOISESWITCH} -H 0 -4 ${SWITCHES}" ################## # Histogram norm # ################## # pnmnorm normalization values if [ $WVALUE != "auto" ]; then PNMNORM1_OPT="-wvalue $WVALUE" PNMNORM2_OPT="-bvalue 0 -wvalue $WVALUE" CS_WVALUE="$WVALUE" else PNMNORM1_OPT="-wpercent 0.005" # 0.005 PNMNORM2_OPT="-bvalue 0 -wpercent 0.005" # 0.005 CS_WVALUE="0.005" fi if [ $BVALUE != "auto" ]; then PNMNORM1_OPT="$PNMNORM1_OPT -bvalue $BVALUE" CS_BVALUE="$BVALUE" elif [ ${SLIDECOPY} == "true" ]; then PNMNORM1_OPT="$PNMNORM1_OPT -bvalue 0" # 0.01 CS_BVALUE="0.01" else PNMNORM1_OPT="$PNMNORM1_OPT -bpercent 0.01" # 0.01 CS_BVALUE="0.01" fi # If the flash fired and Exposure Compensation was set at least # to 0, then we probably intended a "daylight" exposure even if # it came out dull. Therefore allow stronger histogram # stretching. (Using bc allow non-integer comparison) if [ "${FLASH}" == "On, Fired" ] && (( $(bc <<< "${EXPVALUECAM} > 0") )); then MAXEXPAND2=200 else MAXEXPAND2=50 fi ####################################### # Contrast curve and Color saturation # ####################################### SATURATION="110" CONTRAST_CURVE="" CONTRAST_STRETCH="" if [ ${WEDDING} == "true" ]; then SIGMOIDAL_CONTRAST="-sigmoidal-contrast 11x43.5% +sigmoidal-contrast 7.4x60%" elif [ ${VIVID} == "true" ]; then #SM_PARAMm="12x30%" SM_PARAMp="3x60%" #SM_PARAMm="16x32%" SM_PARAMp="9x45%" SATURATION="125" CONTRAST_CURVE="-function Polynomial -3.1858,9.8004,-11.3889,5.6645,0.1051,0.0026" SIGMOIDAL_CONTRAST="-sigmoidal-contrast 4x10%" elif [ ${SLIDECOPY} == "true" ] && [ ${NEGATIVE} == "true" ]; then # For negative slide copying camera can't determine colortemp accurately, so we need to normalize channels individually CONTRAST_STRETCH="-channel RGB -contrast-stretch ${CS_BVALUE}x${CS_WVALUE}% +channel" SIGMOIDAL_CONTRAST="" elif [ ${SLIDECOPY} == "true" ]; then SIGMOIDAL_CONTRAST="-sigmoidal-contrast 4x20% +sigmoidal-contrast 4.5x50%" else # Normal SIGMOIDAL_CONTRAST="-sigmoidal-contrast 4x20% +sigmoidal-contrast 3x35%" fi # For plots of curves see 'sigmoidal_contrast_151206.gnuplot' # -function Polynomial ... -sigmoidal-contrast 4x10 # Vivid # -sigmoidal-contrast 11x43.5 +sigmoidal-contrast 7.4x60 # Wedding 151206 (old wedding: -11x40 +6x60) # -sigmoidal-contrast 4x20 +sigmoidal-contrast 4.5x50 # Slidecopy # -sigmoidal-contrast 4x20 +sigmoidal-contrast 3x35 # Normal ############## # Sharpening # ############## if [ ${SLIDECOPY} == "true" ] && [ ${NEGATIVE} == "true" ]; then SIGMAFACTOR=2.0 #2.0 AMOUNTFACTOR=4.0 #2 elif [ ${SLIDECOPY} == "true" ]; then SIGMAFACTOR=2.0 #2.0 AMOUNTFACTOR=10 #10 elif [ $SIZE = "uhd4k" ]; then SIGMAFACTOR=1.4 AMOUNTFACTOR=3.0 else # default SIGMAFACTOR=1.0 AMOUNTFACTOR=2.0 fi # Smaller amount at higher ISO. (RADIUS=0 implies auto radius) RADIUS=$(calc "${SIGMAFACTOR}*${IMAGE_SIZE}/${SENSOR_SIZE}") # Before 5DM3: 1.0/4368 SIGMA=$(calc "${SIGMAFACTOR}*${IMAGE_SIZE}/${SENSOR_SIZE}") # Before 5DM3: 1.0/4368 NOISEISO=$(calc "(${ISOVALUE}/100)^(1/4)") #^(1/3) AMOUNT=$(calc "${AMOUNTFACTOR}*${SHARP}/${NOISEISO}^2") THRESHOLD=0.0 #0.008 if [ ! ${NOSHARP} == "true" ]; then echo "brewraw: Unsharp filtering settings on luminescence channel: radius=$RADIUS x sigma=$SIGMA" \ "+amount=${AMOUNT} +threshold=${THRESHOLD}" 1>&2 # Sharpen only the luminescence channel in Lab-colorspace to avoid inceasing color noise (L-channel is in Red)! UNSHARP="-profile ${CIELAB_PROFILE} -channel R -unsharp ${RADIUS}x${SIGMA}+${AMOUNT}+${THRESHOLD} +channel" #UNSHARP="-sharpen ${RADIUS}x${SIGMA}" #UNSHARP="-adaptive-sharpen ${RADIUS}x${SIGMA}" else UNSHARP="" fi if [ ! ${NOSHARPTIFF} == "true" ] && [ ${GENERATE_TIF} == "true" ]; then UNSHARPTIFF="${UNSHARP}" UNSHARP="" echo "brewraw: Unsharp applied to TIFF and JPEG..." else UNSHARPTIFF="" echo "brewraw: Unsharp applied to JPEG only..." fi ############# # Filenames # ############# DIR=`dirname $FILE` BASE=`basename $FILE .$ORIG_EXT` if [ "${SUFFIX}" == "defaultsuffix" ]; then JPG_FILE="${DIR}/${BASE}_raw.jpg" if [ ${BITDEPTH} == "16" ]; then TIF_FILE="${DIR}/${BASE}_r16.tif" else TIF_FILE="${DIR}/${BASE}_raw.tif" fi else #SUFFIX=`echo "${FILENAME}" | sed 's/\.[^.]*$//'` JPG_FILE="${DIR}/${BASE}${SUFFIX}.jpg" TIF_FILE="${DIR}/${BASE}${SUFFIX}.tif" fi # Ask user for overwrite permissions. if { [ -e ${JPG_FILE} ] && [ ${GENERATE_JPG} == "true" ] ;} || { [ -e ${TIF_FILE} ] && [ ${GENERATE_TIF} == "true" ] ;}; then NODELETESWITCH=true if [ $OVRWRT == "true" ]; then answer=y else if [ ${GENERATE_TIF} == "true" ] && [ ${GENERATE_JPG} == "false" ]; then echo -n "brewraw: Warning, overwriting existing file: '${TIF_FILE}'... [Y/n] " 1>&2 elif [ ${GENERATE_TIF} == "false" ] && [ ${GENERATE_JPG} == "true" ]; then echo -n "brewraw: Warning, overwriting existing file: '${JPG_FILE}'... [Y/n] " 1>&2 else echo -n "brewraw: Warning, overwriting existing files: '${JPG_FILE}' and '${TIF_FILE}'... [Y/n] " 1>&2 fi read -i "Y" answer fi else answer="" NEW="true" NODELETESWITCH=${NODELETE} fi if [ ${GENERATE_TIF} == "true" ]; then WRITE_TIF="${UNSHARPTIFF} -profile ${OUT_PROFILE_TIFF} -verbose -write tiff:${TIF_FILE}" fi if [ ${GENERATE_JPG} == "true" ]; then WRITE_JPG="${UNSHARP} -profile ${OUT_PROFILE} -verbose -quality 98 -write jpg:${JPG_FILE}" fi if [ $OVRWRT == "true" ]; then BTSWITCH="${BTSWITCH} -o" fi FILES_RAW=${FILE} # Find images for option -blend (multiple exposures) if (($MULTEXP > 1)); then IMAGE_BASE=`expr "$FILE" : '\(.*\)[a-z][0-9][0-9][0-9][0-9].*$'` IMAGE_NR=`expr "$FILE" : '.*\([a-z][0-9][0-9][0-9][0-9]\).*$'` N=1 K=1 while [ $N -lt $MULTEXP ] && [ $K -lt 50 ] do SERIE=`expr "$IMAGE_NR" : '.*\([a-z]\)[0-9][0-9][0-9][0-9].*$'` SEQ_PRE=`expr "$IMAGE_NR" : '.*[a-z]\([0-9][0-9][0-9][0-9]\).*$'` SEQ=$(echo "scale=1; ${SEQ_PRE}+1" | bc -l) [[ $SEQ == [0-9] ]] && SEQ=000$SEQ [[ $SEQ == [0-9][0-9] ]] && SEQ=00$SEQ [[ $SEQ == [0-9][0-9][0-9] ]] && SEQ=0$SEQ if [[ $SEQ == [0-9][0-9][0-9][0-9][0-9] ]]; then SEQ=`expr $SEQ : '.*\([0-9][0-9][0-9][0-9]\).*$'` # We reached above 9999 so increase SERIE letter case "$SERIE" in a) SERIE="b";; b) SERIE="c";; c) SERIE="d";; d) SERIE="e";; e) SERIE="f";; f) SERIE="g";; g) SERIE="h";; h) SERIE="i";; i) SERIE="j";; j) SERIE="k";; k) SERIE="l";; l) SERIE="m";; m) SERIE="n";; n) SERIE="o";; o) SERIE="p";; p) SERIE="q";; q) SERIE="r";; r) SERIE="s";; s) SERIE="t";; t) SERIE="u";; u) SERIE="v";; v) SERIE="w";; w) SERIE="x";; x) SERIE="y";; y) SERIE="z";; z) echo "brewprep: ERROR: end of alphabet in SERIES numbering!!" 1>&2; exit 1;; esac fi IMAGE_NR=$SERIE$SEQ FILE_ADDED=${IMAGE_BASE}${IMAGE_NR}.${ORIG_EXT} if [ -r ${FILE_ADDED} ]; then FILES_RAW="${FILES_RAW} ${FILE_ADDED}"; N=`expr $N + 1`; else K=`expr $K + 1`; fi done if [ ! $K -lt 50 ]; then echo "brewraw: can't find $MULTEXP images to blend within stepping up the image number by 50, skipping..." 1>&2 continue fi fi FILES_PPM=`echo ${FILES_RAW} | sed -e 's/\.'$ORIG_EXT'/\.ppm /g'` # Distortion correction for EF17-40 mm 4.0/L at 20 mm from file /usr/share/lensfun/slr-canon.xml #DISTCORR="-distort barrel 0.015352,-0.035125,0.02436" ############ # Decoding # ############ # Write 16-bit TIFF and convert to 8-bit JPEG if strstr $"yY" "$answer" || [ "$answer" = "" ] ; then if [ -w ${JPG_FILE} ] || [ -w ${TIF_FILE} ] || [ $NEW == "true" ]; then #set -x # enable debugging # ${DCRAW} ${DCR16_SWITCHES} -c ${FILE} | pamfunc -multiplier $(calc "${EXPCOMP}/100") | ${VIGNCORR:-cat} | \ # convert - ${DISTCORR:-} ${EDGE:-} -modulate 100,${SATURATION},100 ${COLORTINT:-} ppm:- | \ # pnmgamma -lineartobt709 | \ # pnmnorm -colorvalue ${PNMNORM1_OPT} -keephues -maxexpand=${MAXEXPAND1} | \ # convert - -gamma ${GAMMA} ${GRAY_SWITCHES} -type Truecolor \ # -intent perceptual -profile ${IN_PROFILE} -profile ${OUT_PROFILE_TIFF} \ # ${CONTRAST_CURVE} ${SIGMOIDAL_CONTRAST} ppm:- | \ # pnmnorm -colorvalue ${PNMNORM2_OPT} -keephues -maxexpand=${MAXEXPAND2} | \ # convert - -profile ${OUT_PROFILE_TIFF} -depth ${BITDEPTH} ${WRITE_TIF} ${WRITE_JPG} \ # ppm:- | cat > /dev/null #set +x for READ_RAW in ${FILES_RAW} do TEMPBASE=`basename ${READ_RAW} .$ORIG_EXT` ${DCRAW} ${DCR16_SWITCHES} -c ${READ_RAW} | ${SCALE:-cat} | pamfunc -multiplier $(calc "${EXPCOMP}/100") | ${VIGNCORR:-cat} | \ convert - ${DISTCORR:-} ${EDGE:-} -modulate 100,${SATURATION},100 ${COLORTINT:-} ppm:- | \ pnmgamma -lineartobt709 | ${INVERT:-cat} | \ pnmnorm -colorvalue ${PNMNORM1_OPT} -keephues -maxexpand=${MAXEXPAND1} | \ convert - -gamma ${GAMMA} ${GRAY_SWITCHES} -type Truecolor \ -intent perceptual -profile ${IN_PROFILE} -profile ${OUT_PROFILE_TIFF} \ ${CONTRAST_STRETCH} ${CONTRAST_CURVE} ${SIGMOIDAL_CONTRAST} ppm:- > ${TEMPBASE}.ppm done if (($MULTEXP > 1)); then echo "align_image_stack: aligning images..." align_image_stack -a /tmp/tempaligned ${FILES_PPM} 1>/dev/null enfuse -o /tmp/temp.ppm --hard-mask --exposure-weight=1 --saturation-weight=0 --contrast-weight=0.5 /tmp/tempaligned* rm ${FILES_PPM} /tmp/tempaligned* else mv ${TEMPBASE}.ppm /tmp/temp.ppm fi cat /tmp/temp.ppm | \ pnmnorm -colorvalue ${PNMNORM2_OPT} -keephues -maxexpand=${MAXEXPAND2} | \ convert - -profile ${OUT_PROFILE_TIFF} -depth ${BITDEPTH} ${WRITE_TIF} ${WRITE_JPG} \ ppm:- | cat > /dev/null #set +x ################## # Postprocessing # ################## # 16-bit or 8-bit TIFF and JPEG if [ ${GENERATE_TIF} == "true" ]; then exiftool -TagsFromFile ${FILE} --Orientation -InteropIndex="${INTEROP_TIFF}" \ -ColorSpace="${COLORSP_TIFF}" -ProcessingSoftware="${SOFTWARE}" -DocumentName="${TIF_FILE}" \ -overwrite_original ${TIF_FILE} fi if [ ${GENERATE_JPG} == "true" ]; then exiftool -TagsFromFile ${FILE} --Orientation -InteropIndex="${INTEROP}" \ -ColorSpace="${COLORSP}" -ProcessingSoftware="${SOFTWARE}" -DocumentName="${JPG_FILE}" \ -overwrite_original ${JPG_FILE} fi if [ ${GENERATE_TIF} == "true" ]; then if [ ! -z "${BREWTOOL}" ]; then brewtool ${BREWTOOL} ${BTSWITCH} ${TIF_FILE} fi if [ ${GENERATE_UHD} == "true" ]; then brewtool 4K ${BTSWITCH} ${TIF_FILE} fi if [ ${GENERATE_GETTY} == "true" ]; then brewtool getty ${BTSWITCH} ${TIF_FILE} fi fi if [ ${GENERATE_JPG} == "true" ]; then if [ ! -z "${BREWTOOL}" ]; then brewtool ${BREWTOOL} ${BTSWITCH} ${JPG_FILE} fi if [ ${GENERATE_WEB} == "true" ]; then # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? brewtool web ${BTSWITCH} ${JPG_FILE} fi if [ ${GENERATE_THUMB} == "true" ]; then # SHOULD ONLY BE DONE ON TIF TO AVOID DOUBLE UNSHARP? brewtool ${THUMBCOMMAND} ${BTSWITCH} ${JPG_FILE} fi fi if [ ${GENERATE_TIF} == "true" ] && [ ${NODELETESWITCH} == "false" ]; then rm ${TIF_FILE} fi if [ ${GENERATE_JPG} == "true" ] && [ ${NODELETESWITCH} == "false" ]; then rm ${JPG_FILE} fi rm /tmp/temp.ppm else echo "brewraw: Target file '${JPG_FILE}' or '${TIF_FILE}' has no write permissions! Skipping..." 1>&2 fi else echo "brewraw: Skipping..." 1>&2 fi echo "" else echo "brewraw: File '$FILE' does not exist or has no write permissions! Skipping..." 1>&2 fi done