Created
December 1, 2020 17:46
-
-
Save Sansui233/21492f8132897d0a3d260ae675c51377 to your computer and use it in GitHub Desktop.
fix image width to 640px with ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "Fix your images width into 640px" | |
| path=$(pwd) | |
| cd $path | |
| echo "\033[34m[Info] Workdir: $path" $(tput sgr0) | |
| files=$(ls $path) | |
| for filename in $files | |
| do | |
| echo "\033[34m[Info] Converting $filename ........." $(tput sgr0) | |
| filenameNoExtension="${filename%.*}" | |
| fileExtension="${filename##*.}" | |
| if [[ "$fileExtension" = "PNG" || "$fileExtension" = "png" ]]; then | |
| ffmpeg -i $filename -vf scale=640:-1 $filenameNoExtension.jpg -y >/dev/null 2>&1 | |
| rm $filename | |
| elif [[ "$fileExtension" = "jpg" || "$fileExtension" = "JPG" ]]; then | |
| ffmpeg -i $filename -vf scale=640:-1 $filename -y >/dev/null 2>&1 | |
| else | |
| echo "\033[33m[WARNING] Unsupported format" $(tput sgr0) | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment