This commit is contained in:
tavo 2025-06-30 00:05:49 -06:00
parent 54726d682e
commit 4ebf5c1085

View file

@ -2,18 +2,34 @@
FILES="$*" FILES="$*"
_error() {
printf "error: %s\n" "$1"
}
DCRAW="${DCRAW:=dcraw}" 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 -w" # Use camera white balance, if possible
DCRAW_OPTS="$DCRAW_OPTS -q 3" # Set the interpolation quality DCRAW_OPTS="$DCRAW_OPTS -q 3" # Set the interpolation quality
DCRAW_OPTS="$DCRAW_OPTS -T" # Write TIFF instead of PPM DCRAW_OPTS="$DCRAW_OPTS -T" # Write TIFF instead of PPM
DCRAW_OPTS="$DCRAW_OPTS -6" # Write 16-bit instead of 8-bit 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 -auto-orient" # Uses EXIF setting 'Orientation'
MAGICK_OPTS="$MAGICK_OPTS -noise 1" # Denoise MAGICK_OPTS="$MAGICK_OPTS -noise 1" # Denoise
MAGICK_OPTS="$MAGICK_OPTS -blur 0x0.5" MAGICK_OPTS="$MAGICK_OPTS -blur 0x0.5"
MAGICK_OPTS="$MAGICK_OPTS -sharpen 0.2x5" MAGICK_OPTS="$MAGICK_OPTS -sharpen 0.2x5"
MAGICK_OPTS="$MAGICK_OPTS -resize x1080"
MAGICK_OPTS="$MAGICK_OPTS -sigmoidal-contrast 6x35%" MAGICK_OPTS="$MAGICK_OPTS -sigmoidal-contrast 6x35%"
MAGICK_OPTS="$MAGICK_OPTS -quality 90" MAGICK_OPTS="$MAGICK_OPTS -quality 90"
MAGICK_OPTS="$MAGICK_OPTS -define jpeg:extent=250kb" MAGICK_OPTS="$MAGICK_OPTS -define jpeg:extent=250kb"
@ -22,20 +38,18 @@ MAGICK_OPTS="$MAGICK_OPTS \
-channel B -evaluate multiply 1.005 \ -channel B -evaluate multiply 1.005 \
-channel RGB +channel" # Remove chromatic aberration -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 for f in $FILES; do
$DCRAW $DCRAW_OPTS $f $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 $MAGICK $MAGICK_OPTS ${f%.*}.tiff ${f%.*}.jpg
rm "${f%.*}.tiff" rm "${f%.*}.tiff"
done done