-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch-cjpegli
More file actions
executable file
·34 lines (25 loc) · 1.03 KB
/
batch-cjpegli
File metadata and controls
executable file
·34 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Define the file extensions to search for
EXTENSIONS=(jpg jpeg JPG JPEG)
JPEGLI_OPTIONS=""
JPEGLI_CMD="docker run --rm -v "$(pwd):/work" imazen/jpegli-tools cjpegli"
echo "Starting JPEG to JXL conversion..."
# Loop through all defined extensions
for ext in "${EXTENSIONS[@]}"; do
# Find files with the current extension
for file in *."${ext}"; do
# Check if the file exists (handles the case where no files match the glob)
if [[ -f "${file}" ]]; then
output_file="${file%.*}.jpg"
echo "Converting ${file} to ${output_file}..."
if $JPEGLI_CMD "${file}" "${output_file}" $JPEGLI_OPTIONS; then
# If conversion is successful, remove the original file
echo "Conversion successful. Removing original ${file}."
rm "${file}"
else
echo "ERROR: cjpegli failed for ${file}. Keeping original file."
fi
fi
done
done
echo "Conversion complete."