Advertisement
JanisPlayer

Untitled

Feb 12th, 2024 (edited)
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.85 KB | Source Code | 0 0
  1. #Für alle, die Speicher sparen wollen:
  2. for file in *.png; do
  3.     cwebp -lossless "$file" -o "${file%.png}.webp" -metadata all -q 100 && touch -r "$file" "${file%.png}.webp" && [ -e "${file%.png}.webp" ] && [ "$(stat -c%s "${file%.png}.webp")" -gt 0 ] && rm "$file"
  4. done
  5.  
  6. #Nur wenn kleiner lossless:
  7. for file in *.png; do
  8.     cwebp -lossless "$file" -o "${file%.png}.webp" -metadata all -q 100 -z 9 && touch -r "$file" "${file%.png}.webp"
  9.    
  10.     if [ -e "${file%.png}.webp" ] && [ "$(stat -c%s "${file%.png}.webp")" -gt 0 ] && [ "$(stat -c%s "$file")" -gt "$(stat -c%s "${file%.png}.webp")" ]; then
  11.         rm "$file"
  12.     else
  13.         rm "${file%.png}.webp"
  14.     fi
  15. done
  16.  
  17. #Für JPEG 100% Qualität:
  18. for file in *.jpg; do
  19.     cwebp "$file" -o "${file%.jpg}.webp" -metadata all -q 100 -z 9 && touch -r "$file" "${file%.jpg}.webp"
  20.    
  21.     if [ -e "${file%.jpg}.webp" ] && [ "$(stat -c%s "${file%.jpg}.webp")" -gt 0 ] && [ "$(stat -c%s "$file")" -gt "$(stat -c%s "${file%.jpg}.webp")" ]; then
  22.         rm "$file"
  23.     else
  24.         rm "${file%.jpg}.webp"
  25.     fi
  26. done
  27.  
  28. #Für JPEG als AVIF mit QL 18:
  29. for file in *.jpg; do
  30.     avifenc "$file" -o "${file%.jpg}.avif" --min 0 --max 18 -s 1 -j 8 && touch -r "$file" "${file%.jpg}.avif"
  31.    
  32.     if [ -e "${file%.jpg}.avif" ] && [ "$(stat -c%s "${file%.jpg}.avif")" -gt 0 ] && [ "$(stat -c%s "$file")" -gt "$(stat -c%s "${file%.jpg}.avif")" ]; then
  33.         rm "$file"
  34.     else
  35.         rm "${file%.jpg}.avif"
  36.     fi
  37. done
  38.  
  39. #Für fast verlustfreies AVIF:
  40. for file in *.jpg; do
  41.     avifenc "$file" -o "${file%.jpg}.avif" --min 0 --max 0 -s 1 && touch -r "$file" "${file%.jpg}.avif"
  42.    
  43.     if [ -e "${file%.jpg}.avif" ] && [ "$(stat -c%s "${file%.jpg}.avif")" -gt 0 ] && [ "$(stat -c%s "$file")" -gt "$(stat -c%s "${file%.jpg}.avif")" ]; then
  44.         rm "$file"
  45.     else
  46.         rm "${file%.jpg}.avif"
  47.     fi
  48. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement