-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch-cjxl
More file actions
executable file
·37 lines (29 loc) · 1.21 KB
/
batch-cjxl
File metadata and controls
executable file
·37 lines (29 loc) · 1.21 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
35
36
37
#!/bin/bash
# Define the file extensions to search for
EXTENSIONS=(jpg jpeg JPG JPEG)
# Set the options for cjxl (e.g., -d 0 for lossless)
# Check 'cjxl --help' for other options
CJXL_OPTIONS="-d 0"
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
# Construct the output filename (.jxl)
output_file="${file%.*}.jxl"
echo "Converting ${file} to ${output_file}..."
# Run the cjxl command
# The '$CJXL_OPTIONS' variable is used for any desired settings
if cjxl --lossless_jpeg=1 "${file}" "${output_file}" $CJXL_OPTIONS; then
# If conversion is successful, remove the original file
echo "Conversion successful. Removing original ${file}."
rm "${file}"
else
echo "ERROR: cjxl failed for ${file}. Keeping original file."
fi
fi
done
done
echo "Conversion complete."