mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 13:03:13 +02:00
- Move all linux_configuration scripts into two semantic categories: - single_use/: scripts run once manually (fresh install, fixes, setup) - periodic_background/: scripts run by systemd timers or daemons - Preserve existing subdirectory structure within each category - Fix lib/common.sh source paths for new directory depths - Fix CONFIG_DIR depth in setup_periodic_system.sh and check_and_enable_services.sh - Update all references in tests, fresh-install/main.sh, nix modules, and docs - Fix check_polling_antipatterns.sh false positives (||, regex |, case patterns, jq strings) - Fix pre-existing mypy exclusion path and type annotations for moved tools/ directory - Rewrite check_polling_antipatterns.sh using awk (no bash regex loops); add require_serial: true
30 lines
887 B
Bash
Executable File
30 lines
887 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Directory containing the images
|
|
directory="./images"
|
|
|
|
# Compression level (default to 0 if not provided)
|
|
compression_level=${1:-0}
|
|
|
|
# Create output directory, overwrite if it already exists
|
|
output_directory="${directory}/webp"
|
|
rm -rf "$output_directory"
|
|
mkdir -p "$output_directory"
|
|
|
|
# Iterate through each file in the directory
|
|
for file in "$directory"/*.{jpg,jpeg,png,bmp,tiff}; do
|
|
# Skip if no matching files are found
|
|
[ -e "$file" ] || continue
|
|
|
|
# Extract the filename without extension
|
|
filename=$(basename "$file")
|
|
filename_no_ext="${filename%.*}"
|
|
|
|
# Convert the file to WebP with specified compression level
|
|
cwebp -q "$compression_level" "$file" -o "$output_directory/${filename_no_ext}.webp"
|
|
|
|
echo "Converted: $file -> $output_directory/${filename_no_ext}.webp"
|
|
done
|
|
|
|
echo "All images have been converted to WebP with compression level $compression_level."
|