#!/bin/bash

input_dir="./public"
output_dir="./public"

mkdir -p "$output_dir"

for input_file in "$input_dir"/*.png; do
    if [ -f "$input_file" ]; then
        filename=$(basename "$input_file" .png)
        output_file="$output_dir/$filename.jpg"
        
        imagemagick "$input_file" "$output_file"

        rm "${input_file}"
        
        echo "Converted $input_file to $output_file"
    fi
done

for input_file in "$input_dir"/*.jpeg; do
    if [ -f "$input_file" ]; then
        filename=$(basename "$input_file" .jpeg)
        output_file="$output_dir/$filename.jpg"
        
        mv "$input_file" "$output_file"
        
        echo "Converted $input_file to $output_file"
    fi
done

echo "Conversion complete!"
