403Webshell
Server IP : 164.138.27.172  /  Your IP : 216.73.216.143
Web Server : nginx/1.27.4
System : Linux cookingdream 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : www-adm ( 1001)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /home/jonasn/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/jonasn/bin/convert-to-webp.sh
#!/bin/bash

# Set the base directory (default to current directory if none given)
BASE_DIR="${1:-.}"
TARGET_USER="www-data"

# Re-run as www-data if needed
if [ "$(whoami)" != "$TARGET_USER" ]; then
  echo "🔐 Switching to $TARGET_USER..."
  exec sudo -u "$TARGET_USER" "$0" "$BASE_DIR"
fi

# Check for cwebp
if ! command -v cwebp &> /dev/null; then
    echo "❌ Error: cwebp not found. Install with 'apt install webp' or equivalent."
    exit 1
fi

echo "🔍 Scanning for images in: $BASE_DIR"

find "$BASE_DIR" -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) | while read -r IMG; do
    WEBP="${IMG}.webp"
    
    if [ -f "$WEBP" ]; then
        echo "✅ Skipping (already exists): $WEBP"
    else
        echo "🔄 Converting: $IMG → $WEBP"
        cwebp -q 90 "$IMG" -o "$WEBP"
    fi
done

echo "🎉 Done converting images to WebP!"


Youez - 2016 - github.com/yon3zu
LinuXploit