From 4ebf5c1085eb6a2907413164d4589bcf5bed5520 Mon Sep 17 00:00:00 2001 From: tavo Date: Mon, 30 Jun 2025 00:05:49 -0600 Subject: [PATCH] longedge --- scripts/rawimage-export | 42 +++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/scripts/rawimage-export b/scripts/rawimage-export index 92f3fd7..e940a52 100755 --- a/scripts/rawimage-export +++ b/scripts/rawimage-export @@ -2,18 +2,34 @@ FILES="$*" +_error() { + printf "error: %s\n" "$1" +} + DCRAW="${DCRAW:=dcraw}" +if ! command -v "$DCRAW" >/dev/null 2>&1; then + _error "dcraw is not in PATH" +fi + +MAGICK="${MAGICK:=convert}" +if ! command -v "$MAGICK" >/dev/null 2>&1; then + _error "magick is not in PATH" +fi + +IDENTIFY="${IDENTIFY:=identify}" +if ! command -v "$IDENTIFY" >/dev/null 2>&1; then + _error "identify is not in PATH" +fi + DCRAW_OPTS="$DCRAW_OPTS -w" # Use camera white balance, if possible DCRAW_OPTS="$DCRAW_OPTS -q 3" # Set the interpolation quality DCRAW_OPTS="$DCRAW_OPTS -T" # Write TIFF instead of PPM DCRAW_OPTS="$DCRAW_OPTS -6" # Write 16-bit instead of 8-bit -MAGICK="${MAGICK:=convert}" MAGICK_OPTS="$MAGICK_OPTS -auto-orient" # Uses EXIF setting 'Orientation' MAGICK_OPTS="$MAGICK_OPTS -noise 1" # Denoise MAGICK_OPTS="$MAGICK_OPTS -blur 0x0.5" MAGICK_OPTS="$MAGICK_OPTS -sharpen 0.2x5" -MAGICK_OPTS="$MAGICK_OPTS -resize x1080" MAGICK_OPTS="$MAGICK_OPTS -sigmoidal-contrast 6x35%" MAGICK_OPTS="$MAGICK_OPTS -quality 90" MAGICK_OPTS="$MAGICK_OPTS -define jpeg:extent=250kb" @@ -22,20 +38,18 @@ MAGICK_OPTS="$MAGICK_OPTS \ -channel B -evaluate multiply 1.005 \ -channel RGB +channel" # Remove chromatic aberration -_error() { - printf "error: %s\n" "$1" -} - -if ! command -v "$DCRAW" >/dev/null 2>&1; then - _error "dcraw is not in PATH" -fi - -if ! command -v "$MAGICK" >/dev/null 2>&1; then - _error "magick is not in PATH" -fi - for f in $FILES; do $DCRAW $DCRAW_OPTS $f + + WIDTH="$($IDENTIFY -format "%w" ${f%.*}.tiff)" + HEIGHT="$($IDENTIFY -format "%h" ${f%.*}.tiff)" + + if [ "$WIDTH" -ge "$HEIGHT" ]; then + MAGICK_OPTS="$MAGICK_OPTS -resize x1080" + else + MAGICK_OPTS="$MAGICK_OPTS -resize 1080x" + fi + $MAGICK $MAGICK_OPTS ${f%.*}.tiff ${f%.*}.jpg rm "${f%.*}.tiff" done