ffmpeg-scripts/compress_img_aesthetic.sh

35 lines
937 B
Bash

#!/bin/bash
# Prompt for input and output directories
read -p "Enter the input directory containing images: " INPUT_DIR
read -p "Enter the output directory for compressed images: " OUTPUT_DIR
# Check if input directory exists
if [ ! -d "$INPUT_DIR" ]; then
echo "Input directory does not exist. Please provide a valid directory."
exit 1
fi
# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"
# Loop through all images in the input directory
for img in "$INPUT_DIR"/*.{jpg,jpeg,png}; do
[ -e "$img" ] || continue
# Get filename without extension
filename=$(basename "$img")
output="${OUTPUT_DIR}/${filename%.*}.jpg"
# Compress and style image without reducing brightness
ffmpeg -i "$img" \
-vf "scale=iw*0.8:ih*0.8,eq=contrast=1.1:saturation=0.8,noise=alls=15:allf=t+u" \
-q:v 3 \
"$output"
echo "Processed $img -> $output"
done
echo "All images processed and saved in $OUTPUT_DIR"